Python 多列数据存储

zip()函数

zip函数可以把多个列表相加成一个tuple(元组)

a = [1,2,3,4]
b = [11,22,33,44]
c = [111,222,333,444]

A = list(zip(a,b,c))

for i in A:
    # print(i)
    print(str(i[0]) + "\t" + str(i[1]) + "\t" + str(i[2]))

结果:
1 11 111 2 22 222 3 33 333 4 44 444

猜你喜欢

转载自www.cnblogs.com/ggtddu/p/11354462.html