試圖讓一個程序來輸入學生姓名和分數,對其進行測試,以確保評分以下是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