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