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(' ', '\n'))
    infopen.close()
    outfopen.close()


delblankline(r'ces\D1.txt', r'ces\1.txt')

 

亲测有效

 

 

原文参考:https://www.jb51.net/article/136706.htm

相关文章:

  • 2022-01-12
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2021-10-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案