def stripFile(oldFile, newFile):
    '''remove the space or Tab or enter in a file, and output a new file in the same folder'''
    f = open(oldFile, 'r+', encoding='utf8')
    newf = open(newFile, 'w',encoding='utf8')
    for eachline in f.readlines():
        newStr = eachline.replace(" ", "").replace("\t","").strip() 
        newf.write(newStr)
    f.close()
    newf.close()


if __name__ == "__main__":
    stripFile("lc_iocapp.postman_collection.json",'lc_iocapp.postman_collection_new.json')

 

去除文件中的空格、tab和回车,重新生成一个新文件。

 

如有更好的方法,请各位大虾不吝赐教!

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-11
  • 2021-11-28
  • 2022-12-23
  • 2021-08-09
  • 2021-11-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-06
  • 2021-11-23
  • 2022-02-04
  • 2021-12-11
  • 2021-12-19
相关资源
相似解决方案