为什么在python中set(None)无效

Lel*_*uge 5 python types set

>>> set(None)
*** TypeError: 'NoneType' object is not iterable

是一个问题,但不是这个:

>>> a=set()
>>> a.add(None)

为什么?

Kar*_*ath 14

正如错误消息告诉您的那样,set()期望一个可迭代的.

set([None])
Run Code Online (Sandbox Code Playgroud)

注:同样是真正的list,tuple...