大文件查找与空格替换

with open(file_name) as file:
    do_something()

多余的空格替换
由于需要用到csv文件(Excel的视图功能,所以需要把连着的空白符替换为逗号,这样方便查看)

import re
file_out = open(filename,"w")
#注意换行
file_out.write(re.sub('s+',',',line).strip() + "
")
#注意最后file_out.close()
原文地址:https://www.cnblogs.com/ply616/p/5864792.html