5.3 for循环

简介: for 循环主要用来遍历列表、字符串、文件等进行操作,默认是循环到最后一个元素为止。test=dict(a=1,b=2,c=3,d=4)for i,j in test.items():    print(i,j)返回结果:a 1b 2c 3d 4 ...

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


目录
打赏
0
0
0
0
6
分享
相关文章
|
5月前
for循环是什么
for循环是什么
93 0
|
5月前
数组去重for循环和for循环嵌套
数组去重for循环和for循环嵌套
48 0
【C++小知识】基于范围的for循环(C++11)
【C++小知识】基于范围的for循环(C++11)
for循环和while循环
for循环和while循环
|
10月前
|
for循环
for循环
65 1
【C++11】 基于范围的for循环
【C++11】 基于范围的for循环
98 0
for循环、while循环和do while循环有什么不同
for循环、while循环和do while循环有什么不同
121 0
for循环与if判断语句的运用
for循环与if判断语句的运用
124 0
C++11之基于范围的for循环
C++11之基于范围的for循环
148 0
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等