当前第2页 返回上一页
相关推荐:《python视频教程》
1 2 | L = list(range(100)) for i in L:
print (i)
|
元组:
1 2 | T = tuple(range(100)) for i in T:
print (i)
|
字典:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | dic = { 'name' : 'chen' , 'age' : 25, 'loc' : 'Tianjin' }
# 以列表的形式返回
keylist(dic.keys())
# 以列表的形式返回
valuelist(dic.values())
# 循环key
for key in dic:
print (key)
# 循环value
for value in dic.values():
print (value)
# 循环key, value
for key, value in dic.items():
print (key, value)
|
字符串:
1 2 3 4 5 | S = 'Say YOLO Again!' for s in S:
print (s)
返回 '索引-元素' 对:
for i, value in enumerate( 'Say YOLO Again.' ):
print (i, value)
|
以上就是python中可迭代对象有哪些的详细内容,更多文章请关注木庄网络博客!!
返回前面的内容
相关阅读 >>
Python如何计时
Python中格式化输出的两种方法介绍
linux如何安装Python
什么是模块?Python中模块module的介绍
Python中pandas和xlsxwriter读写xlsx文件的方法介绍(附代码)
如何获取一个字符的ascii码
Python全局变量和局部变量的区别
Python字典怎么排序
Python中reduce()函数的示例
Python学习之观察者模式
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » python中可迭代对象有哪些