循环,对每个文件:先读入,得到替换后的串,再写入
import os path="E:\lab\批量替换\bvh\" files=os.listdir(path)#获取文件名 i=0 print(len(files)) for i in range(len(files)): with open(path+files[i],"r+") as f: data=f.read() #print(data) data=data.replace("frames :","frames:") data=data.replace("frame Time :","frame Time:") with open(path+files[i],"w+") as f: f.write(data) i+=1
(一通简单粗暴的 *** 作。。。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)