python实现判断数组是否包含指定元素的方法,python数组
python实现判断数组是否包含指定元素的方法,python数组
本文实例讲述了python实现判断数组是否包含指定元素的方法。分享给大家供大家参考。具体如下:
python判断数组是否包含指定的元素的方法,直接使用in即可,python真是简单易懂
print 3 in [1, 2, 3] # membership (1 means true inventory = ["sword", "armor", "shield", "healing potion"] if "healing potion" in inventory: print "You will live to fight another day."
运行结果如下:
True
You will live to fight another day.
希望本文所述对大家的Python程序设计有所帮助。
相关内容
- Python实现将目录中TXT合并成一个大TXT文件的方法,
- Python实现快速多线程ping的方法,python多线程ping
- Python实现数通设备端口使用情况监控实例,python数通
- python连接字符串的方法小结,python字符串小结
- python简单获取数组元素个数的方法,python数组
- 简单上手Python中装饰器的使用,上手python装饰器
- Python读取Excel的方法实例分析,python实例分析
- python检查字符串是否是正确ISBN的方法,pythonisbn
- python实现在字符串中查找子字符串的方法,python中查找
- python字符串对其居中显示的方法,python字符串
评论关闭