class zipobject zipiterables strict=False -- Yield tuples until an input is exhausted listzipabcdefg range3 range4 a 0 0 b 1 1 c 2 2 The zip object yields n-length tuples where n is t
The zip class is a built-in Python class that is used to combine multiple iterators into a single iterator of tuples. It takes one or more iterables as arguments, and returns an iterator that produces tuples containing one element from each of the iterables. The zip function stops when the shortest iterable is exhausted.
For example, zip('abc', [1, 2, 3]) returns an iterator that produces the tuples ('a', 1), ('b', 2), and ('c', 3).
The zip class has the following methods:
__getattribute__(self, name): Returns the value of the named attribute of the object.__iter__(self): Returns the iterator object itself.__next__(self): Returns the next value from the iterator or raisesStopIterationif there are no more values.__reduce__(): Used for pickling.__setstate__(): Used for unpickling.
The zip class also has a static method __new__() that creates and returns a new object
原文地址: https://www.cveoy.top/t/topic/gJ8X 著作权归作者所有。请勿转载和采集!