Skip to main content
 首页 » 编程设计

python之python中的if或语句

2025年05月04日8mfryf

<分区>

wow = ["wowza this is a really long string wows"] 
 
if "long"  or "is" in wow: 
    print("yes") 

输出是是

但是如果我输入

wow = ["wowza this is a really long string wows"] 
 
if "long" in wow: 
print("yes") 

输出是nothing

同上:

 wow = ["wowza this is a really long string wows"] 
 
    if "is" in wow: 
    print("yes") 

为什么?

我认为 或 应该是其中之一? 但是如果单独输入两者都是错误的,但是使用 或 它变成了 true?

或者这是编写 if 或语句的错误方法?

应该这样写吗?

if "long" in wow or "is" in wow: