2. 集合的访问

in / not in 运算符

作用

示例

>>> s = {11, 22, 33}
>>> 22 in s
True
>>> 666 in s
False
>>> 'hello' not in s
True

集合是可迭代对象

集合是可迭代对象。

示例

>>> s = {300, 400, 500}
>>> for x in s:
...     print(x)
...     
400
300
500
视频讲解