1. from collections import Iterator
    from collections import Iterabl
  2.  
  3. dic = {'a':"a","91a":"c"}
  1. print(max(dic)) # 可迭代对象为字典时,取的是键
  2.  
  3. print(max("cd","ft"))
  4.  
  5. def sum1(n):
  6. sum1 = 0
  7. for i in range(n,0,-1):
  8. print(i)
  9. sum1 +=i
  10. return sum1
  11. print(sum1(8))
  12.  
  13. # range() # 是内置函数,产生一个定制的数字范围的整数序列,返回的是一个迭代对象,不能直接取值,通过for循环。
  14. print(range(5),type(range(5)))
  15. print(isinstance(range(5),Iterable)) # True
  16. print(isinstance(range(5),Iterator)) # False
  17. print("__iter__" in dir(range(5))) # True
  18. print("__next__" in dir(range(5))) # False
  19.  
  20. range_iterator = range(5).__iter__() # 将可迭代对象 转换成为 迭代器
  21. # print(range_iterator.__next__())
  22. # print(range_iterator.__next__())
  23. # print(range_iterator.__next__())
  24.  
  25. while True:
  26. try:
  27. item = range_iterator.__next__()
  28. print(item)
  29. except StopIteration:
  30. break
  1. li = [1,3,5,10]
    print(li)
  2.  
  3. print(isinstance(li,Iterable)) # True
  1.  

two week summary的更多相关文章

  1. Summary of Critical and Exploitable iOS Vulnerabilities in 2016

    Summary of Critical and Exploitable iOS Vulnerabilities in 2016 Author:Min (Spark) Zheng, Cererdlong ...

  2. 三个不常用的HTML元素:<details>、<summary>、<dialog>

    前面的话 HTML5不仅新增了语义型区块级元素及表单类元素,也新增了一些其他的功能性元素,这些元素由于浏览器支持等各种原因,并没有被广泛使用 文档描述 <details>主要用于描述文档或 ...

  3. [LeetCode] Summary Ranges 总结区间

    Given a sorted integer array without duplicates, return the summary of its ranges. For example, give ...

  4. Network Basic Commands Summary

    Network Basic Commands Summary set or modify hostname a)     temporary ways hostname NEW_HOSTNAME, b ...

  5. Summary - SNMP Tutorial

    30.13 Summary Network management protocols allow a manager to monitor and control routers and hosts. ...

  6. Mac Brew Install Nginx Summary

    ==> Downloading https://homebrew.bintray.com/bottles/nginx-1.10.1.el_capitan.bot################# ...

  7. Leetcode: LFU Cache && Summary of various Sets: HashSet, TreeSet, LinkedHashSet

    Design and implement a data structure for Least Frequently Used (LFU) cache. It should support the f ...

  8. How to add taxonomy element to a summary view?

    [re: Orchard CMS] This caused me scratching my head for days and now I can even feel it's bleeding. ...

  9. (转) Summary of NIPS 2016

    转自:http://blog.evjang.com/2017/01/nips2016.html           Eric Jang Technology, A.I., Careers       ...

  10. leetcode-【中等题】228. Summary Ranges

    题目: 228. Summary Ranges Given a sorted integer array without duplicates, return the summary of its r ...

随机推荐

  1. 原生js阻止表单跳转

    /* W3C浏览器下的 */ var forms = document.getElementById("from") forms.addEventListener('submit' ...

  2. leaflet实用插件整理

    leaflet实用插件整理: https://www.giserdqy.com/webgis/leaflet/4920/leaflet%E5%AE%9E%E7%94%A8%E6%8F%92%E4%BB ...

  3. hive sql执行的job在map时报java.lang.OutOfMemoryError的错误

    较为详细且重要的一段报错信息是org.apache.hadoop.mapred.YarnChild: Error running child : java.lang.OutOfMemoryError: ...

  4. CentOS 7 搭建CA认证中心实现https取证

    CA认证中心简述 CA :CertificateAuthority的缩写,通常翻译成认证权威或者认证中心,主要用途是为用户发放数字证书 功能:证书发放.证书更新.证书撤销和证书验证. 作用:身份认证, ...

  5. python头部 #!/usr/bin/env python

    *.py运行: python *.py OR ./*.py 对于*.py其首行应标明 #!/usr/bin/env python,定义python解释器调用路径,对比#!/usr/bin/python ...

  6. C#简单打印出LIST集合

    循环打印集合,打印数组,随手写写,新手可以看看, 结果是不是有一些多余的0,把  int [][] ints =new int[3][];  改为new int[2][]; 运行出错,哈哈.  int ...

  7. U-boot2010.06移植--阶段一

    2011-02-24 23:14:57 我今天的移植将分如下3步.加上写记录文档,预计时间3小时. 一,不改变源码,完成编译. 二,修改源码,搭建一个U-boot的框架,完成编译. 三,修改源码,完成 ...

  8. week_one-python格式化输出

    1.多行格式化输出 (1) # Author:larlly name = input("input your name :") age = input("input yo ...

  9. 一个关于cookie的坑

    #问题:今天上午踩了一个坑,首先,这个小案例的运行结果是应该是在前端页面出现一个当前时间的,当然如果是首次登陆的话应该是显示"第一次登陆",第二次则会显示上次的登录时间,但是却没有 ...

  10. 03:CDN原理

    1.1 CDN简介 1.CDN作用(缓存静态资源) 1. CDN的全称Content Delivery Network,(缩写:CDN)即内容分发网络. 2. CDN解决由于网络带宽小.用户访问量大. ...