python_输入输出
2011-05-30 13:36
309 查看
存储器
python中可以把对象存到文件当中,成为永久性的对象。
python中可以把对象存到文件当中,成为永久性的对象。
#!/usr/bin/python # Filename: pickling.py import cPickle as p #import pickle as p shoplistfile = 'shoplist.data' # The name of the file where will be 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
相关文章推荐
- 002_007 Python 随机输入/输出即随机读取文件
- Python输入输出
- Python学习之:输入输出
- Python输入和输出
- 简单讲解Python中的字符串与字符串的输入输出
- Python3 输入和输出
- Python的基本输入输出函数
- Python3 输入和输出
- python 入门-输入输出与基本数据类型
- python输入一个整数,输出该数二进制表示中1的个数
- python基础---输入输出
- A Byte of Python 笔记(10)输入/输出:文件和储存器
- Python进阶01 词典文本文件的输入输出
- Python文件的输入输出
- Python 中对文件的输入输出
- python学习之 输入 输出
- Python输入和输出
- python的输入输出
- python学习(3)输入和输出
- python入门(二)--切换环境,输入与输出