【发布时间】:2016-01-04 14:11:05
【问题描述】:
list1 = ['abra','hello','cfre']
list2 = ['dacc','ex','you', 'fboaf']
ttext = 'hello how are you?'
for i,j in zip(list1, list2):
print i,j
abra dacc
hello ex
cfre you
None fboaf
if (i in ttext and j in ttext):
你好,这个比较列表的相同索引,这里我想查找 ttext 中是否有 'hello' 和 'you'
最好的方法是什么?
【问题讨论】:
-
什么是怪胎 'if (i in ttext and j in text):' ?这是语法错误。
标签: python string python-2.7 enumerate