You can download this code by clicking the button below.
This code is now available for download.
The function combines multiple iterable objects into an iterator, and if the shortest input is exhausted, it fills with a specified fillvalue.
Technology Stack : itertools
Code Type : Function
Code Difficulty : Intermediate
def zip_longest(*args, fillvalue=0):
"""将多个可迭代对象组合成一个迭代器,如果最短的输入迭代完,则用fillvalue填充。
Args:
*args: 可变数量的可迭代对象。
fillvalue: 当最短的输入迭代完时用来填充的值。
Returns:
zip_longest迭代器。
"""
from itertools import zip_longest
return zip_longest(*args, fillvalue=fillvalue)