#!/usr/bin/python
# coding=utf-8
import re
import os
s = os.sep
root = os.getcwd()
for root,dirs,files in os.walk(root):
for name in files:
if name.endswith(".java"):
print(os.path.join(root, name))
a= open(os.path.join(root, name),'r') #打开所有文件
str = a.read()
str = str.replace('sdfsdf','sdf')
b = open(os.path.join(root, name),'w')
b.write(str) #再写入
b.close() #关闭文件
网友评论