You can download this code by clicking the button below.
This code is now available for download.
This function is used to combine multiple iterable objects together. If one of the iterable objects is longer than the others, it will be filled with fillvalue.
Technology Stack : itertools
Code Type : Function
Code Difficulty : Intermediate
def zip_longest(*iterables, fillvalue=None):
"""将可迭代对象组合在一起,如果任何一个可迭代对象被耗尽,则使用fillvalue填充剩余的位置。
Args:
*iterables: 可变数量的可迭代对象。
fillvalue: 当某个可迭代对象被耗尽时使用的填充值。
Returns:
zip对象,它将每个可迭代对象中的元素组合在一起。
"""
from itertools import zip_longest
return zip_longest(*iterables, fillvalue=fillvalue)