2016-02-27 70 views
-3

所以我遇到了一個我正在處理的小項目的問題,問題出現在第10和第18行。由於某些原因,我無法觸發第48行,也無法觸發第48行理解爲什麼?另外我還有一個問題,那就是爲什麼當我輸入一些不應該被程序確認的東西時,比如當程序顯示「請說明你的問題」,並且我要輸入「iajsdb」爲什麼程序不在那裏?相反,它會選擇其中一個結果,如「網絡速度慢還是電話總體?」。也是的,我知道代碼非常混亂,這是我寫的東西的一小部分,如果需要更多的東西來解決這個問題,那麼我會很樂意發佈更多。非常感謝。Python:從文本中選擇單詞

 #Twig2 (iPhone/2g/problem/wet) 
    elif "wet" in iproblem2g.lower(): 
     print ("The chances that your phone will recover from water damage is extremly minimal. You may wish to go to a proffesional and see if any data can be restored, otehrwise you will most likely need to buy a new phone.") 
     applestore = raw_input ("Would you like to find an Apple store near you? ") 
     if "yes" or "sure" or "okay" in applestore: 
      webbrowser.open("http://www.apple.com/retail/") 
     else: 
      print("Troubleshooting complete.") 

    elif "no wifi" or "can't connect" or "cant connect" in iproblem2g.lower(): 
     print("If you cannot connect to your local wifi network then follow these steps:") 
     print("1. Make sure you have a strong signal") 
     print("2. Make sure your wifi is actually on in your settings") 
     print("3. Make sure your wifi network is visible to the public and not invisible.") 
     print("If none of these steps helped then consider going to your local phone repair shop and getting it checked up.") 

      #Twig4 (iPhone/problem/slow) 
    elif "slow" or "lag" in iproblem2g.lower(): 
     slow = raw_input ("Is the internet slow or the phone overall? ") 
     if "net" or "web" in slow: 
      print ("Make sure that your slow connection isn't caused by a weak signal.") 
      nettips = raw_input ("Would you like to be redirected to a page with tips to speed up your internet? ") 

回答

1

您沒有正確使用if。您應該使用:

elif "no wifi" in iproblem2g.lower() or "can't connect" in iproblem2g.lower() or "cant connect" in iproblem2g.lower(): 
elif "slow" in iproblem2g.lower() or "lag" in iproblem2g.lower(): 

等等(重複的條件下,or使得它評估爲True所有的時間,無論你輸入的)...

相關問題