python的存储
来源:互联网 发布:阿里云免费邮箱入口 编辑:程序博客网 时间:2024/05/23 11:52
代码:
#!/usr/bin/python# Filename: pickling.pyimport cPickle as p#import pickle as pshoplistfile = 'shoplist.data'# the name of the file where we will store the objectshoplist = ['apple', 'mango', 'carrot']# Write to the filef = file(shoplistfile, 'w')p.dump(shoplist, f) # dump the object to a filef.close()del shoplist # remove the shoplist# Read back from the storagef = file(shoplistfile)storedlist = p.load(f)print storedlist
程序运行结果:
['apple', 'mango', 'carrot']
shoplist.data的内容:
(lp1S'apple'p2aS'mango'p3aS'carrot'p4a.
dump()出来的文件还是要用load()来读比较好。
- python的存储
- python变量的存储格式
- python—DataFrame的存储
- Python 关于python的数据存储方面
- Python数据磁盘存储pickle-决策树的存储
- 用户密码的存储与Python示例
- Python对MySQL存储过程的调用
- 用户密码的存储与 Python 示例
- python list存储的是reference id
- 用户密码的存储与 Python 示例
- python对象的存储与读取
- 用pickle存储Python的原生对象
- Python存储数据库时候随机数的问题
- Python读取MATLAB存储的mat文件
- [转]Python字符串的编码转换、存储
- python 线性表的链式存储
- 使用python存储网页上的图片
- python读取存储matlab的 .mat文件
- Object_C 宏的定义格式
- simple_captcha
- window下查看端口命令
- 《深入理解Linux内核》读书笔记-第二章-内存寻址(2)
- 浅析container_of(ptr, type, member)
- python的存储
- 二维码生成与解析代码实现
- vs2010 和 sqlserver 2008 安装全过程
- eclipse for php (DPT) xdebug 配置 调试php
- SAP外部顾问应该有的素质
- 编程求21位的水仙花数,大家给讲讲思路呗,,谢谢了、、
- 搭建Python的Eclipse开发环境之安装PyDev插件
- 线程(AsyncQueryhandler)
- 短网址对SEO的影响与应用