Python shelve模块的使用方法

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = '人生入戏' import shelve,time
#写
x = shelve.open("shelve_test")
name = ["jack","tom","人生入戏"]
a = {"name":"jack","age":20}
time_log = time.time()
x["name"] = name
x["a"] = a
x["time_log"] = time_log
x.close()
#读
x = shelve.open("shelve_test")
print(x.get("name"))
print(x.get("a"))
print(x.get("time_log"))
x.close()

在当前目录 下生成shelve_test.bak shelve_test.dat shelve_test.dir,保存在这几个目录下

程序读的结果如下:

['jack', 'tom', '人生入戏']
{'name': 'jack', 'age': 20}
1502718534.106106
上一篇:snmpv3-snmpd.conf解析


下一篇:Appium Python API