更新时间:2022-02-20 21:59:33
我推荐你使用 搁置.例如:
I recommend you use shelve. For example:
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()
它将从磁盘读取.如果需要,您可以使用此技术以相同的方式保存分数列表.
and it will be read from disk. You can use this technique to save a list of scores if you want in the same way.