Python开发环境

Python 3.6.0

具体代码

注:Python3 开始 file() 方法将被 open() 方法代替

1
2
3
4
5
6
fp1=open('1.txt','r')
fp2=open('2.txt','w')
for s in fp1.readlines():
fp2.write(s.replace('\t',','))
fp1.close()
fp2.close()

注解

  • fp1 指定需要被修改的文本文件
  • fp2 指定修改后的文本文件
  • replace(s1,s2) 把 s1 替换成 s2