私はPythonにかなり慣れていません。制御された評価のためにこのコードを作成しましたが、「q11」(Webを開く最初のコマンド)が定義されていないことを示唆しています。それは他のものと同じで、以前はうまく機能していましたが、今は再び作業を開始しましたが、機能しません。
前もって感謝します
これが私のコードです:
import webbrowser
import random
sol1 = ("Check if there is lint in the charging ports. This can be removed carefully with a toothpick or similar implement")
sol2 = ("Turn on assistive touch if you have an iphone (settings > general > accessability > assistive touch until you go to a shop to get them replaced. If you use android, download 'button savior' from the google play store")
sol3 = ("Do a hard reset - hold down the power and home buttons until the screen turns off and keep them held down until the screen turns on again ")
sol4 = ("Restore the phone to factory settings and set it up as new")
sol5 = ("You need a screen replacement.")
sol6 = ("You may need to replace the battery.")
sol7 = ("You dont need to do anything. Your phone doesnt have any problems.")
sol8 = ("Please update your phone software.")
sol9 = ("Contact apple for support")
sol10 = ("Take the phone and put it in a bag of rice for 24-36 hours to let the rice absorb the water.")
q1=input("Is your phone charging correctly? ")
if q1 == "no":
print(sol1)
if q1 == "yes":
q2=input("Is your phone water damaged? ")
if q2 == "yes":
print(sol10)
if q2 == "no":
q3=input("Is the screen cracked or badly scratched? ")
if q3 == "yes":
print(sol5)
if q3 == "no":
q4=input("Is the phone working slowly and crashing? ")
if q4 == "yes":
print(sol3)
if q4 == "no":
q5=input("Do you wish to remove data from the phone? ")
if q5 == "yes":
print(sol4)
if q5 == "no":
q6=input("Does the phone work without issues? ")
if q6 == "yes":
print(sol7)
if q6 == "no":
q7=input("Are you running the lastest software version? ")
if q7 == "no":
print(sol8)
if q7 == "yes":
q8=input("Are the buttons producing accurate responses ")
if q8 == "no":
print(sol2)
if q8 == "yes":
q9=input("Is your phone battery draining and dying early? ")
if q9 == "yes":
print(sol6)
if q9 == "no":
q10=input("Does the phone turn on, even if it has been charged with a working charger? ")
if q10 == "yes":
print(sol9)
if q10 == "no":
q11=input("Would you like to visit the apple support site?: yes/no ")
if q11 == "yes":
webbrowser.open("https://support.apple.com/en-gb")
if q11 == "no":
q12=input("Would you like to visit the genius bar booking site?: yes/no ")
if q12 == "yes":
webbrowser.open("https://getsupport.apple.com/")
if q12 == "no":
print( "このサービスをご利用いただきありがとうございます。お役に立てば幸いです")
了解しました。しばらくの間これに取り組んでおり、次のコードを追加しました。
list = []
q1 = str(input("Is your phone charging correctly? "))
characters = len(q1)
for i in range(characters):
lowercase = str.lower(q1[i])
list.append(lowercase)
q1 = ("".join(list))
文字変数は、q1に入力された文字数をカウントします。たとえば、「yes」と入力すると3文字、「no」と入力すると2文字がカウントされます。
この小文字の変数は、文字列全体をループする小文字に入力するものを基本的に設定します。文字数をループするforループを作成しました。(例:「YES」と入力すると、長さは3として保存され、文字列「YES」の各文字をループしてすべて「yes」に変更します。)
文字列の長さが必要な理由は、文字列がないと正しい回数をループできなかったためです。(例:2のループを配置した場合、「YES」と入力すると、文字列を2回通過するだけで、「ye」として保存され、3番目の文字は含まれません。ループが2の場合も同様で、保存されます。 'y'として。
list.append(lowercase)
このlist.appendは基本的に、最初のループの文字「y」をこの['y']のようなリストに追加し、次に2番目のループでこの['y'、 'e']のような「e」と3番目のループを追加します['はい']
q1 = ("".join(list))
この部分は基本的に、先ほど作成したリスト['y'、 'e'、 's']を、回答の変数であるq1という文字列に結合します。それを「はい」に結合します。
そもそも小文字への変更を追加した理由は、「はい」、「yES」、「はい」などと入力した場合などです。回答が引き続き機能するように、常にすべて小文字に変更されます。
import webbrowser
import random
sol1 = ("Check if there is lint in the charging ports. This can be removed carefully with a toothpick or similar implement")
sol2 = ("Turn on assistive touch if you have an iphone (settings > general > accessability > assistive touch until you go to a shop to get them replaced. If you use android, download 'button savior' from the google play store")
sol3 = ("Do a hard reset - hold down the power and home buttons until the screen turns off and keep them held down until the screen turns on again ")
sol4 = ("Restore the phone to factory settings and set it up as new")
sol5 = ("You need a screen replacement.")
sol6 = ("You may need to replace the battery.")
sol7 = ("You dont need to do anything. Your phone doesnt have any problems.")
sol8 = ("Please update your phone software.")
sol9 = ("Contact apple for support")
sol10 = ("Take the phone and put it in a bag of rice for 24-36 hours to let the rice absorb the water.")
list = []
q1 = str(input("Is your phone charging correctly? "))
characters = len(q1)
for i in range(characters):
lowercase = str.lower(q1[i])
list.append(lowercase)
q1 = ("".join(list))
if q1 == "no":
print(sol1)
list = []
if q1 == "yes":
q2 = str(input("Is your phone water damaged? "))
for i in range(len(q2)):
lowercase = str.lower(q2[i])
list.append(lowercase)
q2 = ("".join(list))
if q2 == "yes":
print(sol10)
list = []
if q2 == "no":
q3 = str(input("Is the screen cracked or badly scratched? "))
for i in range(len(q3)):
lowercase = str.lower(q3[i])
list.append(lowercase)
q3 = ("".join(list))
if q3 == "yes":
print(sol5)
list = []
if q3 == "no":
q4 = str(input("Is the phone working slowly and crashing? "))
for i in range(len(q4)):
lowercase = str.lower(q4[i])
list.append(lowercase)
q4 = ("".join(list))
if q4 == "yes":
print(sol3)
list = []
if q4 == "no":
q5 = str(input("Do you wish to remove data from the phone? "))
for i in range(len(q5)):
lowercase = str.lower(q5[i])
list.append(lowercase)
q5 = ("".join(list))
if q5 == "yes":
print(sol4)
list = []
if q5 == "no":
q6 = str(input("Does the phone work without issues? "))
for i in range(len(q6)):
lowercase = str.lower(q6[i])
list.append(lowercase)
q6 = ("".join(list))
if q6 == "yes":
print(sol7)
list = []
if q6 == "no":
q7 = str(input("Are you running the lastest software version? "))
for i in range(len(q7)):
lowercase = str.lower(q7[i])
list.append(lowercase)
q7 = ("".join(list))
if q7 == "no":
print(sol8)
list = []
if q7 == "yes":
q8 = str(input("Are the buttons producing accurate responses "))
for i in range(len(q8)):
lowercase = str.lower(q8[i])
list.append(lowercase)
q8 = ("".join(list))
if q8 == "no":
print(sol2)
list = []
if q8 == "yes":
q9 = str(input("Is your phone battery draining and dying early? "))
for i in range(len(q9)):
lowercase = str.lower(q9[i])
list.append(lowercase)
q9 = ("".join(list))
if q9 == "yes":
print(sol6)
list = []
if q9 == "no":
q10 = str(input("Does the phone turn on, even if it has been charged with a working charger? "))
for i in range(len(q10)):
lowercase = str.lower(q10[i])
list.append(lowercase)
q10 = ("".join(list))
if q10 == "yes":
print(sol9)
list = []
if q10 == "no":
q11 = str(input("Would you like to visit the apple support site?: yes/no "))
for i in range(len(q11)):
lowercase = str.lower(q11[i])
list.append(lowercase)
q11 = ("".join(list))
if q11 == "yes":
webbrowser.open("https://support.apple.com/en-gb")
list = []
if q11 == "no":
q12 = str(input("Would you like to visit the genius bar booking site?: yes/no "))
for i in range(len(q12)):
lowercase = str.lower(q12[i])
list.append(lowercase)
q12 = ("".join(list))
if q12 == "yes":
webbrowser.open("https://getsupport.apple.com/")
else:
print()
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加