熱線電話:13121318867

登錄
首頁精彩閱讀python實現判斷數組是否包含指定元素的方法
python實現判斷數組是否包含指定元素的方法
2018-07-15
收藏

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程序設計有所幫助。

數據分析咨詢請掃描二維碼

若不方便掃碼,搜微信號:CDAshujufenxi

數據分析師資訊
更多

OK
客服在線
立即咨詢
日韩人妻系列无码专区视频,先锋高清无码,无码免费视欧非,国精产品一区一区三区无码
客服在線
立即咨詢