Python 检查集合中是否存在项目
检查集合中是否存在项目
要确定指定项目是否出现在集合中,请使用 in
关键字
示例
检查 "apple" 是否出现在集合中
thisset = {"apple", "banana", "cherry"}
if "apple" in thisset
print("Yes, 'apple' is in this set")
自己试试 »
要确定指定项目是否出现在集合中,请使用 in
关键字
检查 "apple" 是否出现在集合中
thisset = {"apple", "banana", "cherry"}
if "apple" in thisset
print("Yes, 'apple' is in this set")
自己试试 »
If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]
If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]