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

 

最后修改于 2020-03-16 20:55:55
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付
上一篇