我建议您搁置。例如:
import shelve
d = shelve.open('score.txt') # here you will save the score variable
d['score'] = score # thats all, Now it is saved on disk.
d.close()
下次打开程序时,请使用:
import shelve
d = shelve.open('score.txt')
score = d['score'] # the score is read from disk
d.close()
它将从磁盘读取。如果需要,可以使用此技术保存分数列表。