python list,dict的储存于读取

安装pickle

pip install  pickle
存储
data = [1, 2, 3]
path = r'..\static\filename'
with open(path, "wb") as f:
    pickle.dump(data, f)
f.close()
读取
path = r'..\static\filename'
with open(path, "rb") as f:
    data = pickle.load(f)
f.close()

你可能感兴趣的:(python list,dict的储存于读取)