对(可选的)类型声明表示敬意!
您开始将其格式化为字符串有点太早了。最好将您的对的结构保留更长的时间:
for pair in sorted_by_second:
f.write(f'{pair}\n')
或者,如果您愿意,可以将它们分开以获得更灵活的格式:
for name, points in sorted_by_second:
f.write(f'{name} scored {points}.\n')
翻过高山走不出你
相关分类