练习,替换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')
小白白又白
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')