关于python列表 for 循环的问题
a = ['1','2','3','4','5','6']b = ['a','b','c','d','e','f']
for i in a:
print(i)
for j in b:
print(j)
上面代码输出的是
1
2
3
4
5
6
a
b
c
d
e
f
如果我想要的是一一对应输出 :如1 a,2 b,3 c
应该怎么操作呢{:10_316:} 多线程或把他们合并为一个列表 import threading
a = ['1','2','3','4','5','6']
b = ['a','b','c','d','e','f']
def c():
for i in a:
print(i)
thread = threading.Thread(target=c)
thread.start()
for j in b:
print(j)
a = ['1','2','3','4','5','6']
b = ['a','b','c','d','e','f']
for i, j in zip(a, b):
print(i, j) fori,j in zip(a,b):
print(i,j) 青出于蓝 发表于 2021-7-24 21:09
啊这,多线程可海星
多浪费{:10_245:} qiuyouzhi 发表于 2021-7-24 22:04
啊这,多线程可海星
多浪费
涨知识了.............. 感谢各位大佬 {:5_109:} 两个长度一样也可以这样操作啊
a = ['1','2','3','4','5','6']
b = ['a','b','c','d','e','f']
for i in range(len(a)):
print(a,b)
新手作答
页:
[1]