检查字符串是否包含任何列表元素

Jos*_*lly 5 python list

所以我正在做一个列表的 for 循环。我想要 .find 每一个字符串,但不是 .find 某个字符串的一项,而是检查该字符串中列表中的任何内容。

例如。

checkfor = ['this','that','or the other'] 
Run Code Online (Sandbox Code Playgroud)

然后做

string.find(checkfor) 或其他东西,所以我想这样做:

if email.find(anything in my checkforlist) == -1:
    do action
Run Code Online (Sandbox Code Playgroud)

cri*_*007 1

我想检查该字符串是否有列表中的任何内容

Python 有in这个功能。

for s in checkfor:
    if s in email:
        # do action 
Run Code Online (Sandbox Code Playgroud)