python pickle 复原导致的变量关系丢失问题
运行 python 时,可以将当前的某些变量通过 pickle 序列化到二进制文件中;然后在需要时,再将这些变量还原,如以下代码:
import pickle
f = open("abc.pickle", 'wb+')
x = [1,2,3]
ls = [[(23, 29), (22, 79)], 'hello信息', '35',x]
num = 3.1415926
pickle.dump(ls, f)
pickle.dump(num, f)
pickle.dump(x, f)
print(id(x),id
原创
2022-05-22 23:33:49 ·
432 阅读 ·
0 评论