2016-02-27 69 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所有的时间,无论你输入的)...

相关问题