十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
python处理下数据小脚本
创新互联是专业的邓州网站建设公司,邓州接单;提供成都网站建设、成都做网站,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行邓州网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!
# -*- coding:UTF-8 -*-
import os
def wenjchuli(file_path):
with open(file_path) as f, open(file_path+".bak", 'w') as f2:
for line in f:
if("Location" in line):
new_line=line.replace(line,"")
elif("Qualified Name" in line):
new_line=line.replace(line,"")
elif ("JD-Core Version" in line):
new_line = line.replace(line, "")
elif ("/*" in line):
new_line = line[12:].replace("/", "")
else:
new_line = line
f2.write(new_line)
os.remove(file_path)
os.rename(file_path+".bak",file_path)
def gci(filepath):
# 遍历filepath下所有文件,包括子目录
files = os.listdir(filepath)
for fi in files:
fi_d = os.path.join(filepath, fi)
if os.path.isdir(fi_d):
gci(fi_d)
else:
wenjchuli(fi_d)
gci("C:\\Users\\lw\\Desktop\\letv")