```python
# -*- coding: utf-8 -*-
'''
遇到文中的空格就换行
'''
def delblankline(infile, outfile):
infopen = open(infile, 'r',encoding="utf-8")
outfopen = open(outfile, 'w',encoding="utf-8")
db = infopen.read()
outfopen.write(db.replace(' ','
'))
infopen.close()
outfopen.close()
delblankline("jb51.txt", "o3.txt")
```
Python3 replace()方法
描述
replace() 方法把字符串中的 old(旧字符串) 替换成 new(新字符串),如果指定第三个参数max,则替换不超过 max 次。