我有一個包含1個元素的數組。此元素包含: 打印(results_read [0])Python檢查數組元素是否包含字符串
[(u'n04019541', u'puck', 0.57829314), (u'n02974003', u'car_wheel', 0.24903433), (u'n03483316', u'hand_blower', 0.025689969), (u'n02910353', u'buckle', 0.015434729), (u'n04542943', u'waffle_iron', 0.012205523)]
如何檢查它是否包含 'car_wheel'? 我想:
if 'car_wheel' in results_read:
print('yes')
else:
print('no')
是否有任何其他方式做到這一點?
http://stackoverflow.com/questions/3437059/does-python-have-a-string-contains-substring-method的副本 – yar