python3中zip出现的错误

参考:https://blog.csdn.net/oMoDao1/article/details/82150972

 

在python3中输入print zip会出现:zip object at 0x000001F5D1731840

 

例如:

t1 = [1,2,3]
t2 = [9,8,7]
zipped = zip(t1,t2)
print(zipped)

报错信息:

<zip object at 0x000001F5D1731840>

 

在python3里zip后的结果是一个遍历对象。

正确输入为:

t1 = [1,2,3]
t2 = [9,8,7]
zipped = zip(t1,t2)
for i in zipped:
    print(i)

输出结果:

(1, 9)
(2, 8)
(3, 7)

 

posted @ 2020-05-13 16:11  shenyin  阅读(865)  评论(0编辑  收藏  举报