好吧我有下面的代碼執行一些我不希望它做的事情。如果你運行該程序,它會問你「你好嗎?」 (很明顯),但是當你給出適用於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