yield函数为什么返回的是seen的值 而不是item
def quchu(items): seen = set() for item in items: if item not in seen: yield item seen.add(item) if __name__ == '__main__': a = [1,4,3,4,3,5,8] print(a) print(list(quchu(a)))
#学习路径#
def quchu(items): seen = set() for item in items: if item not in seen: yield item seen.add(item) if __name__ == '__main__': a = [1,4,3,4,3,5,8] print(a) print(list(quchu(a)))
相关推荐
招聘动态