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() + "\n")
#注意最后file_out.close()
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() + "\n")
#注意最后file_out.close()
相关文章: