for 循环主要用来遍历列表、字符串、文件等进行操作,默认是循环到最后一个元素为止。
test=dict(a=1,b=2,c=3,d=4)
for i,j in test.items():
print(i,j)
返回结果:
a 1
b 2
c 3
d 4
本文转自 归来仍少年 51CTO博客,原文链接:http://blog.51cto.com/shaoniana/1976261
for 循环主要用来遍历列表、字符串、文件等进行操作,默认是循环到最后一个元素为止。
test=dict(a=1,b=2,c=3,d=4)
for i,j in test.items():
print(i,j)
返回结果:
a 1
b 2
c 3
d 4