代码拉取完成,页面将自动刷新
#add
#update
#remove
#discard
#pop
#clear
# 创建
st1 = set("zhaoxiaobo")
print(type(st1), st1)
st2 = {1, 2.3}
print(type(st2), st2)
st3 = {i for i in range(100, 120)}
print(type(st3), st3)
st5 = {1, True, 2}
print(st5)
st6 = {3, 7, 21, 42, 19}
print(5 in st6)
print(5 not in st6)
st7 = {1, 2, 3}
st7.add(666)
print(st7)
st7.add(2)
print(st7)
st8 = {1, 2, 3}
st8.update("Maximo")
print(st8)
st9 = {1, "老刘", 2, 4, 78}
st9.remove("老刘")
print(st9)
st9.discard("老刘")
print(st9)
st10 = {"吃鸡","老李",3,5,7}
luck = st10.pop()
print(luck)
st11 = {"吃鸡"}
luck = st11.pop()
print(luck,type(luck))
st12 = {1, "老刘", 2, 4, 78}
st12.clear()
print(f"st12:{st12}")
st13 = set()
print(type(st13))
st_a = {1,2,5}
st_b = {2,8,9}
result = st_a.intersection(st_b)
print(result)
print(st_a & st_b)
result = st_a.union(st_b)
print(result)
print(st_a | st_b)
result = st_a.difference(st_b)
print(result)
print(st_a - st_b)
st14 ={c for c in "hello"}
print(st14)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。