#!/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 hhjwqh
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了修改文件相关的知识,希望对你有一定的参考价值。
以上是关于修改文件的主要内容,如果未能解决你的问题,请参考以下文章