修改文件

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re

file= open("cs.py","r",encoding = 'utf-8')
lines=file.readlines()
file.close()
strinfo = re.compile('^([\d\s])+')
file_data = ""
for line in lines:
if re.match("^([\d\s])+",line):
line=strinfo.sub("",line)
file_data +=line


with open("cs.py","w",encoding="utf-8") as f:
f.write(file_data)
posted @ 2018-02-10 20:08  hhjwqh  阅读(146)  评论(0)    收藏  举报