pickle Example

写入文件

import pickle

integers = [1, 2, 3, 4, 5]

with open('pickle-example.p', 'wb') as pfile:
pickle.dump(integers, pfile)

读取文件

import pickle

with open('pickle-example.p', 'rb') as pfile:
integers = pickle.load(pfile)
print integers

shelve Example

写入文件

import shelve

integers = [1, 2, 3, 4, 5]

# If you're using Python 2.7, import contextlib and use
# the line:
# with contextlib.closing(shelve.open('shelf-example', 'c')) as shelf:
with shelve.open('shelf-example', 'c') as shelf:
shelf['ints'] = integers

读取文件

import shelve

# If you're using Python 2.7, import contextlib and use
# the line:
# with contextlib.closing(shelve.open('shelf-example', 'r')) as shelf:
with shelve.open('shelf-example', 'r') as shelf:
for key in shelf.keys():
print(repr(key), repr(shelf[key])))

最新文章

  1. 使用javax.persistence注解配置PO对象
  2. JAVA多线程编程之生产者消费者模式
  3. HashMap和Hashtable及HashSet的区别
  4. Vijos 1061 迎春舞会之三人组舞(DP)
  5. 消除QQ表情小游戏
  6. C# Json数据反序列化为Dictionary并根据关键字获取指定值
  7. Java 编程下使用 Class.forName() 加载类
  8. Android AES加密算法及事实上现
  9. 重新想象 Windows 8 Store Apps (19) - 动画: 线性动画, 关键帧动画, 缓动动画
  10. 为什么C++没有对应realloc的new操作符呢?
  11. 设计模式 --> (13)备忘录模式
  12. SAP MM 无价值物料管理的一种实现思路
  13. 创建一个MongoDB数据库再到配置成Window服务再设置用户名密码
  14. [TJOI2009]猜数字
  15. Oracle的条件in中包含NULL时的处理
  16. centos系统安装rar解压工具unar
  17. js运行机制
  18. Java学习笔记48(DBUtils工具类一)
  19. Windows 下使用 MinGW 和 CMake 进行开发
  20. courator - create

热门文章

  1. Vue 响应式属性
  2. MFC的运行机理分析+ASC码问题
  3. POJ 2253 Frogger(最小最大距离)
  4. Pandoc PDF 中文
  5. Linux模块机制浅析_转
  6. eval(function(p,a,c,k,e,d){e=function(c)加解密
  7. 【转】【selenium+Python WebDriver】之元素定位不到解决办法
  8. Redis单台的安装部署及集群部署
  9. C语言的运算符的优先级与结合性+ASCII表
  10. LeetCode222——Count Complete Tree Nodes