所以这是我的代码
a="yes"
b="no"
c=a[0].upper() + a[1:]
d=b[0].upper() + b[1:]
e=a.upper()
f=b.upper()
def shut_down(s):
if s == a or c or e:
return "Shutting down..."
if s == b or d or f:
return "Shutdown aborted"
else:
return"yeah"
因此,当我调用该函数时,它没有正确执行(它没有运行所有 if 语句)我是 python 新手,不知道为什么会这样,但是当我像下面这样重做工作时,它的工作原理是故意的
a="yes"
b="no"
c=a[0].upper() + a[1:]
d=b[0].upper() + b[1:]
e=a.upper()
f=b.upper()
def shut_down(s):
if s == a:
return "Shutting down..."
if s== e:
return "Shutting down..."
if s ==c:
return "Shutting down..."
if s == b:
return "Shutdown aborted!"
if s == d:
return "Shutdown aborted!"
if s == f:
return "Shutdown aborted!"
else:
return "Sorry, I didn't understand you."
谁能告诉我为什么会这样