two week summary
- from collections import Iterator
from collections import Iterabl- dic = {'a':"a","91a":"c"}
- print(max(dic)) # 可迭代对象为字典时,取的是键
- print(max("cd","ft"))
- def sum1(n):
- sum1 = 0
- for i in range(n,0,-1):
- print(i)
- sum1 +=i
- return sum1
- print(sum1(8))
- # range() # 是内置函数,产生一个定制的数字范围的整数序列,返回的是一个迭代对象,不能直接取值,通过for循环。
- print(range(5),type(range(5)))
- print(isinstance(range(5),Iterable)) # True
- print(isinstance(range(5),Iterator)) # False
- print("__iter__" in dir(range(5))) # True
- print("__next__" in dir(range(5))) # False
- range_iterator = range(5).__iter__() # 将可迭代对象 转换成为 迭代器
- # print(range_iterator.__next__())
- # print(range_iterator.__next__())
- # print(range_iterator.__next__())
- while True:
- try:
- item = range_iterator.__next__()
- print(item)
- except StopIteration:
- break
- li = [1,3,5,10]
print(li)- print(isinstance(li,Iterable)) # True
two week summary的更多相关文章
- Summary of Critical and Exploitable iOS Vulnerabilities in 2016
Summary of Critical and Exploitable iOS Vulnerabilities in 2016 Author:Min (Spark) Zheng, Cererdlong ...
- 三个不常用的HTML元素:<details>、<summary>、<dialog>
前面的话 HTML5不仅新增了语义型区块级元素及表单类元素,也新增了一些其他的功能性元素,这些元素由于浏览器支持等各种原因,并没有被广泛使用 文档描述 <details>主要用于描述文档或 ...
- [LeetCode] Summary Ranges 总结区间
Given a sorted integer array without duplicates, return the summary of its ranges. For example, give ...
- Network Basic Commands Summary
Network Basic Commands Summary set or modify hostname a) temporary ways hostname NEW_HOSTNAME, b ...
- Summary - SNMP Tutorial
30.13 Summary Network management protocols allow a manager to monitor and control routers and hosts. ...
- Mac Brew Install Nginx Summary
==> Downloading https://homebrew.bintray.com/bottles/nginx-1.10.1.el_capitan.bot################# ...
- 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 ...
- 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. ...
- (转) Summary of NIPS 2016
转自:http://blog.evjang.com/2017/01/nips2016.html Eric Jang Technology, A.I., Careers ...
- leetcode-【中等题】228. Summary Ranges
题目: 228. Summary Ranges Given a sorted integer array without duplicates, return the summary of its r ...
随机推荐
- 原生js阻止表单跳转
/* W3C浏览器下的 */ var forms = document.getElementById("from") forms.addEventListener('submit' ...
- leaflet实用插件整理
leaflet实用插件整理: https://www.giserdqy.com/webgis/leaflet/4920/leaflet%E5%AE%9E%E7%94%A8%E6%8F%92%E4%BB ...
- hive sql执行的job在map时报java.lang.OutOfMemoryError的错误
较为详细且重要的一段报错信息是org.apache.hadoop.mapred.YarnChild: Error running child : java.lang.OutOfMemoryError: ...
- CentOS 7 搭建CA认证中心实现https取证
CA认证中心简述 CA :CertificateAuthority的缩写,通常翻译成认证权威或者认证中心,主要用途是为用户发放数字证书 功能:证书发放.证书更新.证书撤销和证书验证. 作用:身份认证, ...
- python头部 #!/usr/bin/env python
*.py运行: python *.py OR ./*.py 对于*.py其首行应标明 #!/usr/bin/env python,定义python解释器调用路径,对比#!/usr/bin/python ...
- C#简单打印出LIST集合
循环打印集合,打印数组,随手写写,新手可以看看, 结果是不是有一些多余的0,把 int [][] ints =new int[3][]; 改为new int[2][]; 运行出错,哈哈. int ...
- U-boot2010.06移植--阶段一
2011-02-24 23:14:57 我今天的移植将分如下3步.加上写记录文档,预计时间3小时. 一,不改变源码,完成编译. 二,修改源码,搭建一个U-boot的框架,完成编译. 三,修改源码,完成 ...
- week_one-python格式化输出
1.多行格式化输出 (1) # Author:larlly name = input("input your name :") age = input("input yo ...
- 一个关于cookie的坑
#问题:今天上午踩了一个坑,首先,这个小案例的运行结果是应该是在前端页面出现一个当前时间的,当然如果是首次登陆的话应该是显示"第一次登陆",第二次则会显示上次的登录时间,但是却没有 ...
- 03:CDN原理
1.1 CDN简介 1.CDN作用(缓存静态资源) 1. CDN的全称Content Delivery Network,(缩写:CDN)即内容分发网络. 2. CDN解决由于网络带宽小.用户访问量大. ...