Receives two or more sequences and returns a list of tuples, and each tuple list contains the first element from each sequence
" ABC " = [11,23,45]print(Zip (s,t)) for in Zip (s,t): Print (pair) Print (List (Zip (s,t)))
D:\Python\Python35\python.exe d:/pycharmprojects/helloworld/src/ziptest.py
<zip Object at 0x00000201d6459648>
(' a ', 11)
(' B ', 23)
(' C ', 45)
[(' A ', one-to-one), (' B ', '), (' C ', 45)]
Process finished with exit code 0
The sequence length of the zip is different, then take the short one.
The number is not the same: t length is greater than s
s ="ABC"T= [11,23,45,77,88]Print(Zip (s,t)) forPairinchZip (s,t):Print(pair)Print(list (Zip (s,t))) D:\Python\Python35\python.exe D:/pycharmprojects/helloworld/src/ziptest.py<zip Object at 0x00000252de5b96c8>('a', 11)('b', 23)('C', 45)[('a', 11), ('b', 23), ('C', 45)]process finished with exit code 0
The number is not the same, s length is greater than t
s ="Abcer"T= [11,23,45]Print(Zip (s,t)) forPairinchZip (s,t):Print(pair)Print(list (Zip (s,t))) D:\Python\Python35\python.exe D:/pycharmprojects/helloworld/src/ziptest.py<zip Object at 0x0000024c7e2c9648>('a', 11)('b', 23)('C', 45)[('a', 11), ('b', 23), ('C', 45)]process finished with exit code 0
"Python" built-in function zip