Python中的文件存储
#!/usr/bin/pythonpoem = '''\Programming is runWhen the work is doneif you wanna make your work also fun:using python'''f = file('poem.txt', 'w')f.write(poem)f.close()f = file('poe
·
#!/usr/bin/python
poem = '''\
Programming is run
When the work is done
if you wanna make your work also fun:
using python
'''
f = file('poem.txt', 'w')
f.write(poem)
f.close()
f = file('poem.txt', 'r')
while True:
lineText = f.readline()
if 0 == len(lineText):
break;
print lineText,
f.close()
#!/usr/bin/python
import cPickle as p
alibaba = ['taobao', 'alipay', 'tmall', 'aliyun', 'cainiao', '1688']
f = file('ali88.data', 'w')
p.dump(alibaba, f)
f.close()
del alibaba
f = file('ali88.data')
alibaba = p.load(f)
f.close()
print alibaba
更多推荐
已为社区贡献1条内容
所有评论(0)