所以我正在做一个列表的 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)
我想检查该字符串是否有列表中的任何内容
Python 有in这个功能。
for s in checkfor:
if s in email:
# do action
Run Code Online (Sandbox Code Playgroud)