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."




 

posted @ 2019-09-04 11:08  marguerite103  阅读(18516)  评论(0编辑  收藏  举报