您如何按降序在txt文件上制作排行榜?

我想知道如何将分数(与名称绑定)以降序重新排列到外部文件。

我的代码是:

name = input("Please enter your name:\n\n")
p1 = int(input("Please enter a number:\n"))

p2 = int(input("Please enter another number:\n"))

totalp = (p1+p2)

file = open("GameScores.txt","a+")

file.write(name +",\t")
file.write(format(totalp))
file.write("\n")
file.close()

请注意,这是一个草稿程序,因此它不应该很健壮-我只是用它来测试更高级的程序。

shenhaizhe 回答:您如何按降序在txt文件上制作排行榜?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2998404.html

大家都在问