f = file('test','rb') fout = file('test.out','wb') #fout = file('test.out','w+b')
for i in range(10): a = f.read(1) fout.write(a) f.close() f = fout f.seek(4) print f.read(4)
本文展示了如何使用Python的文件操作函数进行文件的读取与写入操作,包括打开文件、读取数据、关闭文件及定位文件指针等基本步骤。
f = file('test','rb') fout = file('test.out','wb') #fout = file('test.out','w+b')
for i in range(10): a = f.read(1) fout.write(a) f.close() f = fout f.seek(4) print f.read(4)
2517
1885
6万+

被折叠的 条评论
为什么被折叠?