python shelve模块,pythonshelve,[Python]代码de
python shelve模块,pythonshelve,[Python]代码de
[Python]代码
def CreateData(): try: db = shelve.open('db.dat', 'c') # key与value必须是字符串 db['int'] = 1 db['float'] = 2.3 db['string'] = "I like python." db['key'] = 'value' finally: db.close() def LoadData(): db = shelve.open('db.dat', 'r') for item in db.items(): print item db.close() if __name__ == '__main__': CreateData() LoadData() import shelvedef CreateData(): try: db = shelve.open('db.dat', 'c') # key与value必须是字符串 db['int'] = 1 db['float'] = 2.3 db['string'] = "I like python." db['key'] = 'value' finally: db.close()def LoadData(): db = shelve.open('db.dat', 'r') for item in db.items(): print item db.close()if __name__ == '__main__': CreateData() LoadData()
相关内容
- Python anydbm模块,pythonanydbm模块,[Python]代码im
- Python CET查分,pythoncet查分,[Python]代码#!
- Django-缓存机制详解,django-机制详解,1.设定缓存 缓存选
- PycURL 实现POST方法,pycurl实现post,[Python]代码im
- PycURL 自动处理cookie,PycURL处理cookie,[Python]代码im
- Python 使用xlrd读取Excel格式文件,pythonxlrd,[Python]代码i
- Python Daemon(守护进程),pythondaemon,[Python]代码de
- Python os.path.walk遍历文件,搜索文件里面的内容,pytho
- Python decorator,pythondecorator,[Python]代码转载
- Python 去除代码前行号,python去除代码前行,[Python]代码
评论关闭