去除行首空格的Python脚本

最近才发现,使用博客园的代码高亮的时候会在每行前添加一个空格,然后不得不一个个地把空格删掉,把代码高亮风格也换掉。

为了节省时间,用python写了个小脚本:

#coding=utf8
#!/usr/bin/env python
def delspace(file): txt=open(file,'r') newtxt=open('new.txt','w') lines=txt.readlines() for line in lines: newline=line[1:] newtxt.write(newline) txt.close() newtxt.close()
原文地址:https://www.cnblogs.com/catmelo/p/2941332.html