小编use*_*538的帖子

elif只触发if语句

使用python 2.7.5

x = (raw_input)'''What will you Reply?
a. Nod
b. Answer
c. Stare
'''))

if x == "Nod" or "a" or "nod":
    print '''You nod shyly.
"Oh that's Great"'''
elif x == "Answer" or "b" or "answer":
    print '''You answer in a low tone.
"You can speak!"'''
elif x == "Stare" or "c" or "stare":
    print '''you stare blankly, so does the AI.
"Well okay then."'''
Run Code Online (Sandbox Code Playgroud)

当我运行它时,无论我在提示中输入什么,它只会触发'''你害羞地点头."哦,太好了"'''

但是,如果我复制它并将其粘贴到我的python shell中,它有一个"哦"的问题,如果我摆脱它,它有一个问题在"那是",如果我只是摆脱"这是伟大的"它对下一个elif语句的前三个字符有问题.WTF是错误的,我的python代码和shell最近工作正常,能够拆分if和elif.但现在突然间它只是不想.

python

1
推荐指数
1
解决办法
108
查看次数

标签 统计

python ×1