Python~迭代
2016-04-05 18:29
381 查看
dict | #默认情况下,dict迭代的是key | 迭代value | #迭代key,value |
for value in d.itervalues(): | for k,v in d.iteritems(): | ||
#迭代字符串 | for ch in 'ABCD123': | ||
#判断是否是可迭代对象 isinstance | 字符串 | list | |
from collections import Iterable | isinstance('abc',Iterable) | isinstance([1,2,3],Iterable) | isinstance(123,Iterable) |
enumerate函数
for i,value in enumerate(['a','b','c']): print i,value
相关文章推荐
- python time 与datetime之间的区别与联系
- Python描述符(descriptor)解密
- Python~切片Slice
- python version 2.7 required,which was not found in the registry
- 理解Python中的with…as…语法
- Python如何安装egg组件
- python常用内置模块,执行系统命令的模块
- Leetcode 15. 3Sum(python)
- Python3.5入门学习记录-条件控制
- odoo8新旧API related字段类型详解
- python小技巧
- jenkins+python持续集成
- Leetcode 14. Longest Common Prefix(python)
- python学习过程-字典和文件操作
- Python使用PDFMiner解析PDF
- 在Xcode7中搭建python开发环境
- python数据库模块
- 在windows7(64位)下, keras的安装及错误处理
- python字典和集合,frozenset和哈希值
- if __name__ == '__main__'在python中的应用