Python/gloss python add set items
来自菜鸟教程
<languages />
Python添加集项目
添加套装物品
要将一个项目添加到集合中,请使用
add()
方法。
要将多个项目添加到集合中,请使用
update()
方法。
例
使用
add()
方法:
thisset = {"apple", "banana", "cherry"}
thisset.add("orange")
print(thisset)
例
使用
update()
方法:
thisset = {"apple", "banana", "cherry"}
thisset.update(["orange",
"mango", "grapes"])
print(thisset)