Python 如果语句中不包含

Python 如果语句中不包含,python,string,if-statement,Python,String,If Statement,当我只查找一个字符串时,这个if语句有效 body = json.dumps(work['Body'])[2:-2] if len(something) >= 1 and 'SMILE' in body: print " i'm happy" 但当我在寻找多个字符串时,这一个没有 body = json.dumps(work['Body'])[2:-2] if len(something) >= 1 and 'SMILE' or

当我只查找一个字符串时,这个if语句有效

    body = json.dumps(work['Body'])[2:-2]
    if len(something) >= 1 and 'SMILE' in body:
           print " i'm happy"
但当我在寻找多个字符串时,这一个没有

    body = json.dumps(work['Body'])[2:-2]
    if len(something) >= 1 and 'SMILE' or 'LAUGH' or 'LOVE' or 'CHEER' in body:
           print " i'm still happy "
有什么好处?
如何在if条件下使多个字符串与另一个字符串匹配?

假设body是某个字符串,可以使用以下操作:


什么会是相反的。。。所以我想说“不在”。。。我想要另一个if语句,它说如果那些关键字不在字符串中,那么执行xyz?您也可以使用。或者
不是所有(…)
或任何组合,这取决于您想要什么。@user3467359
和not any(
将是相反的
或者
在Python中不是连词;它是一个布尔运算符。它所做的事情远不及英语连词“或”所做的。
# for example
body='SMILE_LAUGH_SOMESTRING_WHTATEVER'
if len(something) >= 1 and any(s in body for s in ('SMILE', 'LAUGH', 'LOVE', 'CHEER')):
     print("i'm still happy")