移动文件指针来操作文件

with open('file2.conf','r+') as f:
try:
#f.seek(210)
#conts=f.read(80)
f.seek(292)
#print(f.tell())
f.write('YYYYYYYYYYYYYYYYYYYY\n')
conts=f.read(80)
print(conts)
except RuntimeError as e:
print(e)

posted @ 2021-02-25 13:59  笑傲运维  阅读(42)  评论(0编辑  收藏  举报