Python zip避坑

Python zip() 函数

最近使用zip函数时出现了一些错误,简单记录一下。有错误的地方,欢迎大佬批评。

初始化几个列表
Python zip避坑
输出结果:
Python zip避坑

zip基本用法:从多个列表中各自依次取出一个元素组合,组合后的元素个数为较短数组中元素个数

Python zip避坑
输出结果:
Python zip避坑
避坑1:无法直接使用print(C)打印
Python zip避坑
输出结果:
Python zip避坑
避坑2:zip返回的是一个迭代器
Python zip避坑
输出结果:
Python zip避坑

python中的函数还有很多,日后慢慢学习。