1.python中如何把一段文字中的空格替换成换行符
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(r'cesD1.txt', r'ces1.txt')
亲测有效
原文参考:https://www.jb51.net/article/136706.htm