试图让一个程序来输入学生姓名和分数,对其进行测试,以确保评分以下是vaule> = 0和< = 100,将结果保存到一个文件和环回运行在蟒蛇
gradeFile = open("grade.dat","a")
Score = "0"
while Score>=0:
Name = raw_input("What is the students's name?: ")
Score = float(raw_input("What is the students's score?: "))
while Score <0 or Score >100 :
print("ERROR: the grade cannot be less than 0 or more than 100")
Score = float(raw_input("What is the students's score?: "))
gradeFile.write(Name+"\n")
gradeFile.write(Score+"\n")
gradeFile.close()
print("Data saved to grade.dat")
gradeFile.write(得分+ “\ n”)为您提供了错误'类型错误:对于不支持+操作数类型(S): '浮动' 和“str'',您可以将其更改为gradeFile.write(str(Score)+“\ n”) – ton1c
您没有提出任何问题。你需要回答什么问题? – user2357112