练习,替换txt文档中的信息

import os
with open('b','a+',encoding= 'utf-8') as f,open('b2.bak','w',encoding= 'utf-8') as f2:
f.seek(0)
for i in f:
new_i = i.replace('一','二')
f2.write(new_i)
os.remove('b')
os.rename('b2.bak','b')

posted on 2020-04-02 11:05  奥喵  阅读(177)  评论(0编辑  收藏  举报

导航