python迭代器增加元素、iterator拼接

    技术2023-07-05  64

    方法肯定有好多种,目前用的觉得还不错的是下面这种

    import itertools iter1 = iter([1,2,3]) iter2 = iter([4,5,6]) iter3 = itertools.chain(iter1, iter2)

    赞: https://stackoverflow.com/questions/571850/adding-elements-to-python-generators https://stackoverflow.com/questions/1264319/need-to-add-an-element-at-the-start-of-an-iterator-in-python

    Processed: 0.011, SQL: 9