文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>python_输入输出

python_输入输出

时间:2011-05-30  来源:邵国宝

存储器

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
相关阅读 更多 +
排行榜 更多 +
幣安BNB币行情神器

幣安BNB币行情神器

金融理财 下载
愤怒的火柴人4中文版下载

愤怒的火柴人4中文版下载

角色扮演 下载
嘟嘟脸恶作剧手游下载

嘟嘟脸恶作剧手游下载

休闲益智 下载