Python 检查集合中是否存在某个项
检查集合中是否存在某个项
要确定集合中是否存在指定的项,请使用 in
关键字
示例
检查集合中是否存在“apple”
thisset = {"apple", "banana", "cherry"}
if "apple" in thisset
print("是的,'apple' 在此集合中")
自己动手试一试 »
要确定集合中是否存在指定的项,请使用 in
关键字
检查集合中是否存在“apple”
thisset = {"apple", "banana", "cherry"}
if "apple" in thisset
print("是的,'apple' 在此集合中")
自己动手试一试 »
如果您想将 W3Schools 服务用于教育机构、团队或企业,请发送电子邮件给我们
sales@w3schools.com
如果您想报告错误,或想提出建议,请发送电子邮件给我们
help@w3schools.com