1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| file="E:\\笔记\\python\\面向对象_hexo.md" import re,os def alter(old_str,new_str): path = "E:\\笔记\\python" for root, dirs, files in os.walk(path): if root == "E:\\笔记\\python": for file in files: file1 = os.path.join(root,file) file2=file.split(".") if file2[1] == "md": with open(file1, "r", encoding="utf-8") as f1,open("%s.bak" % file1, "w", encoding="utf-8") as f2: for line in f1: f2.write(re.sub(old_str,new_str,line)) os.remove(file1) os.rename("%s.bak" % file1, file1) alter(https://yinshiweiysw.github.io/images/assets/')
|