1)上代码test.py
import os
import sys
import re
# like ./stringstream_output.py ./test
SOURCE_PATH=""
FUNCTION="\tfriend TSCOMMON_EXPORT stringstream& operator<<(stringstream& ss, const "
OUTSTREAM=""
ERRNO=0
EXP_WORDS=re.compile(r'\w+')
results=[]
if (len(sys.argv) < 2):
ERRNO=1
exit (ERRNO)
SOURCE_PATH=sys.argv[1]
print "---------------------------"
for root,dirs,files in os.walk(SOURCE_PATH):
for file in files:
if (file.find('.new')!=-1):
continue
start = False
NEW_TXT_STRING=""
FUNCTIOIN_STRING=""
source_file_name=SOURCE_PATH
source_file_name+='//'
source_file_name+=file
new_file_name = source_file_name + '.new'
fd = open(source_file_name,"r")
new_fd = open(new_file_name, "w")
for line in fd.read