我正在尝试制作一个将分数发送到文本文件的程序 你能帮到我的代码是
吗?if cn == "1":
fi = open("class1.txt","w")
fi.write("\n" + str(name) + ":" + str(score))
fi.close ()
答案 0 :(得分:-2)
while questionNo == 10 and score >= 0:
if schClass == '1':
inFile = open("scores1.txt", 'a')
inFile.write("\n" + name + " : " + str(score))
inFile.close()
score = -1
elif schClass == '2':
inFile = open("scores2.txt", 'a')
inFile.write("\n" + name + " : " + str(score))
inFile.close()
score = -1
elif schClass == '3':
inFile = open("scores3.txt", 'a')
inFile.write("\n" + name + " : " + str(score))
inFile.close()
score = -1