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' 在这个集合中")
W3School 简体中文版提供的内容仅用于培训和测试,不保证内容的正确性。通过使用本站内容随之而来的风险与本站无关。版权所有,保留一切权利。
关于 W3School 帮助 W3School 使用条款 隐私条款 技术支持:赢科 蒙 ICP 备 06004630 号