python替換文件夾下全部文件中的指定字符串

import sys
import os
from sys import  argv
file_name = argv[1]

path = 'file/'
for file in os.listdir(file_name):
	dir_entry_path = os.path.join(path,file);
	print  dir_entry_path
	f = open(dir_entry_path,'r')
	rc = f.read().replace('aaa','jjj')
	f.close()
	t =open(dir_entry_path,'w')
	t.write(rc)
	t.close()
相關文章
相關標籤/搜索