>>> list(zip(‘abcd‘,[1,2,3]))
[(‘a‘, 1), (‘b‘, 2), (‘c‘, 3)]
>>> list(zip(‘abcd‘))
[(‘a‘,), (‘b‘,), (‘c‘,), (‘d‘,)]
>>> list(zip(‘123‘,‘abc‘,‘,.! ‘))
[(‘1‘, ‘a‘, ‘,‘), (‘2‘, ‘b‘, ‘.‘), (‘3‘, ‘c‘, ‘!‘)]
>>> for item in zip(‘abcd‘,range(3)):
... print(item)
...
(‘a‘, 0)
(‘b‘, 1)
(‘c‘, 2)
>>> x = zip(‘abcd‘,‘1234‘)
>>> list(x)
[(‘a‘, ‘1‘), (‘b‘, ‘2‘), (‘c‘, ‘3‘), (‘d‘, ‘4‘)]
>>> list(x)
[]
原文:https://www.cnblogs.com/zxbdboke/p/10468416.html