您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。