⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pickling.py

📁 《简明 Python 教程》为 "A Byte of Python" 的唯一指定简体中文译本
💻 PY
字号:
#!/usr/bin/env python
# Filename: pickling.py

import cPickle as p
#import pickle as p

shoplistfile='shoplist.data'
# the name of the file where we will store the object

shoplist=['apple','mango','carrot']

# Write to the file
f=file(shoplistfile,'w')
p.dump(shoplist,f) # dump the object to a file
f.close()

del shoplist # remove the shoplist

# Read back from the storage
f=file(shoplistfile)
storedlist=p.load(f)
print storedlist

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -