我可以用它來確定是否有任何一組多個字符串的另一個字符串存在,蟒蛇 - 多串找到多個字符串
bar = 'this is a test string'
if any(s in bar for s in ('this', 'test', 'bob')):
print("found")
,但我不知道如何檢查是否有在多個字符串中的任意一個字符串中都會出現。這似乎是可行的。在語法上它並沒有失敗,但它不會是打印我出什麼:
a = 'test string'
b = 'I am a cat'
c = 'Washington'
if any(s in (a,b,c) for s in ('this', 'test', 'cat')):
print("found")
啊好 - 這是有道理的。謝謝! –