好吧我有下面的代码执行一些我不希望它做的事情。如果你运行该程序,它会问你“你好吗?” (很明显),但是当你给出适用于elif语句的问题的答案时,我仍然得到一个if语句响应。为什么是这样?如何解决Python elif?
talk = raw_input("How are you?")
if "good" or "fine" in talk:
print "Glad to here it..."
elif "bad" or "sad" or "terrible" in talk:
print "I'm sorry to hear that!"
+1 - 很好的解释。 – duffymo 2010-11-16 03:01:17