-1
我正在製作一個程序,該程序是識別關鍵字的手機故障排除程序,然後根據所述關鍵字讀取並打印具有解決方案的文檔。現在用我的代碼,我問問題是什麼,如果我說液體,我想要液體文件打印和一系列與液體問題有關的問題提出。現在,當我這樣做時,它一直在問第一組問題,這是權力。任何人都可以幫助我,所以它會出現一系列問題嗎?獲取代碼以在一個變量下提問另一組問題
#Task 2 Trouble-Shooter 1.0
#Zacharriah River Howells
import time
print('Hello and welcome to the mobile phone Trouble-Shooter!')
time.sleep(2)
problem = input('Please input what is wrong with your phone')
if "power" in problem:
f = open('Power.txt', 'r')
solution1 = f.readlines()
print(solution1[0])
f.close()
if "battery" in problem:
f = open('Power.txt', 'r')
solution1 = f.readlines()
print(solution1[0])
f.close()
time.sleep(2)
print('Have you charged your phone overnight? if not do so')
time.sleep(1)
powerans = input('Does your phone turn on now?')
if powerans == 'yes':
f = open('Power.txt', 'r')
solution1 = f.readlines()
print(solution1[1])
f.close()
exit()
elif powerans == 'no':
f = open('Power.txt', 'r')
solution2 = f.readlines()
print(solution2[2])
f.close()
exit()
if "liquid" in problem:
f = open('Liquid.txt', 'r')
solution1 = f.readlines()
print(solution1[0])
f.close()
if "water" in problem:
f = open('Liquid.txt', 'r')
solution1 = f.readlines()
print(solution1[0])
f.close()
time.sleep(2)
print('Have you let your phone dry in a container filled with rice?')
time.sleep(1)
liquidans = input('Does your phone turn on now?')
if liquidans == 'yes':
f = open('Liquid.txt', 'r')
solution1 = f.readlines()
print(solution3[1])
f.close()
exit()
elif liquidans == 'no':
f = open('Liquid.txt', 'r')
solution2 = f.readlines()
print(solution4[2])
f.close()
exit()
if "software" in problem:
f = open('Software.txt', 'r')
solution1 = f.readlines()
print(solution1[0])
f.close()
if "apps" in problem:
f = open('Software.txt', 'r')
solution1 = f.readlines()
print(solution1[0])
f.close()
time.sleep(2)
print('Have you tried reinstalling the app?')
time.sleep(1)
softeareans = input('Does your phone turn on now?')
if softwareans == 'yes':
f = open('Software.txt', 'r')
solution1 = f.readlines()
print(solution5[1])
f.close()
exit()
elif softwareans == 'no':
f = open('Software.txt', 'r')
solution2 = f.readlines()
print(solution6[2])
f.close()
exit()
if "hardware" in problem:
f = open('Hardware.txt', 'r')
solution1 = f.readlines()
print(solution1[0])
f.close()
if "display" in problem:
f = open('Hardware.txt', 'r')
solution1 = f.readlines()
print(solution1[0])
f.close()
time.sleep(2)
print('Have you tried installing the newest system update?')
time.sleep(1)
hardwareans = input('Does your phone turn on now?')
if hardewareans == 'yes':
f = open('Hardware.txt', 'r')
solution1 = f.readlines()
print(solution7[1])
f.close()
exit()
elif hardwareans == 'no':
f = open('Hardware.txt', 'r')
solution2 = f.readlines()
print(solution8[2])
f.close()
exit()
if "unable" in problem:
f = open('Unidentifiable.txt', 'r')
solution1 = f.readlines()
print(solution1[0])
f.close()
if "dunno" in problem:
f = open('Unidentifiable.txt', 'r')
solution1 = f.readlines()
print(solution1[0])
f.close()
time.sleep(2)
print('We cannot identify uour problem you can either')
time.sleep(1)
print('Visit our store')
time.sleep(1)
print('Visit our website')
loop = input('Would you like to return to the start of the trouble-shooter?')
if loop == 'yes':
problem()
else:
exit()
告訴我們什麼是不工作。 – DyZ
歡迎來到StackOverflow。請閱讀並遵守幫助文檔中的發佈準則。 [最小,完整,可驗證的示例](http://stackoverflow.com/help/mcve)適用於此處。在發佈您的MCVE代碼並準確描述問題之前,我們無法爲您提供有效的幫助。 – Prune