python判断数组是否包含指定的元素的方法的代码


在研发闲暇时间,将内容过程较好的一些内容做个记录,如下的内容段是关于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."




 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM