score = open("scores.txt", "r")
scoretable = score.readlines()
score.close()
score1 = scoretable
score1.sort(reverse=True)
for score in score:
strippedline = score.strip()
print(strippedline)
splitline = strippedline.split(" " , 1)
print(splitline)
print(splitline.sort())
score = int(splitline[0])
print(score)
f=open('top5.txt','w')
for ele in score1:
f.write(ele)
f.close()
这是我将代码“ score”中的项目放到“ top5”中的基本代码。
我希望获得5分最高得分的基本排行榜风格,但会出现错误