嘿,我有一個非常簡單的問題,但是我希望修復它的所有地方似乎都不起作用。所以對於學校我們必須做到這一點,我們將用戶輸入保存到excel文件中,並在其中執行Mylist.append(電話)時出現錯誤,說明電話未定義。任何想法如何解決這個問題?我的代碼中的名稱錯誤
#Zacharriah Task 3
import csv
from IPhone import*
from Android import*
import time
def start():
print('Hello Welcome to the Phone Trouble-Shooter')
time.sleep(2)
phone = input('Please input what brand of phone you have')
if "iphone" in phone:
print('Your phone has been identified as an Iphone')
elif "android" in phone:
print('Your phone has been identifies as an Android')
file = open("Excel_Task_3.csv", "w", newline = "")
fileWrite = csv.writer(file,delimiter = ",")
Mylist = []
Mylist.append(phone)
fileWriter.writerow(Mylist)
file.close()
所以修復做我把高清手機下DEF開始? –
查看更新。基本上你必須確保變量存在於你想要使用的範圍內。 –
噢,謝謝它的工作:) –