python处理下数据小脚本
# -*- 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")
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。