我遇到了如下代码
l = [1, 2]
s = set()
# the same results from the following two
s.update(set(l))
s.update(l)
为什么这两个得到相同的结果?是因为两者都是可迭代的吗?
最佳答案
Note, the non-operator versions of update(), intersection_update(), difference_update(), and symmetric_difference_update() will accept any iterable as an argument.
关于python 设置更新列表或设置(列表),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44070238/