嘿,我有一个非常简单的问题,但是我希望修复它的所有地方似乎都不起作用。所以对于学校我们必须做到这一点,我们将用户输入保存到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开始? –
查看更新。基本上你必须确保变量存在于你想要使用的范围内。 –
噢,谢谢它的工作:) –