扫码关注官方订阅号
listone = [a,b,c,d]listtwo = [1,2,3,4]
请问如何写循环,使得循环结果为[a,1],[b,2]……
这不就是zip吗
题主不用zip要用双循环?
zip
listone = ['a', 'b', 'c', 'd'] listtwo = [1, 2, 3, 4] listtwo_iter = iter(listtwo) l = [] for x in listone: for y in listtwo_iter: l.append([x, y]) break print l
这样?
print zip(listone,listtwo)
(逃
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
这不就是zip吗
题主不用
zip要用双循环?这样?
(逃