码迷,mamicode.com
首页 > 其他好文 > 详细

修改文件

时间:2018-02-10 20:48:16      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:修改   import   ack   utf-8   usr   font   lin   adl   com   

#!/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)

修改文件

标签:修改   import   ack   utf-8   usr   font   lin   adl   com   

原文地址:https://www.cnblogs.com/hhjwqh/p/8439637.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!