“Python/gloss python check if set item exists”的版本间差异
来自菜鸟教程
小 (Pywikibot 4.4.0.dev0) |
小 (机器人:添加分类Python基础教程) |
||
第43行: | 第43行: | ||
</div> | </div> | ||
<br /> | <br /> | ||
+ | |||
+ | [[分类:Python基础教程]] |
2020年10月29日 (四) 08:48的最新版本
<languages />
Python检查集中是否存在项目
检查项目是否存在于集合中
要确定集合中是否存在指定的项目,请使用
in
关键词:
例
检查集合中是否存在“苹果”:
thisset = {"apple", "banana", "cherry"} if "apple" in thisset: print("Yes, 'apple' is in this set")