The usage of python serialization, you can save the value of the variable to the file, so that you can pickle it when you open it next time

import pickle as p
a=[5,8,9]
b="dkgjdkj"
c="你好"
fp=open("d:\\a.txt","wb")
p.dump(a.fp)
p.dump(b.fp)
p.dump(c.fp)
fp.close()

#关闭以上程序后,再次打开程序执行以下代码
import pickle as p
fp=open("d:\\a.txt","rb")
a=p.load(fp) #a的值为[5,8,9],先进先出的原则
b=p.load(fp) #b的值为"dkgjdkj"
c=p.load(fp) #c的值为"你好"
fp.close()

Guess you like

Origin blog.csdn.net/weixin_44123630/article/details/111568991