INSERT INTO TTT (NSAME, ID, AGE) VALUES ('AAA', '201023210816', '22');
将上面的SQL格式改成以下的格式
AAA|201023210816|22
import os
lists=[]
paths = os.getcwd()
for root,dirs,files in os.walk('wfyh'):
for fn in files:
lists.append(fn)
for nmb in lists:
dfile=open("wfyh\\"+nmb,'r')
nmbb=nmb.replace('.sql','')
ofile=open("wf_test\\"+nmbb+'.txt','w')
lists=[]
for line in dfile:
m=line.split('(')[2].replace(');','').replace(', ','|').replace('\'','')
t = ''.join(m.split())
lists.append(t)
for linet in lists:
ofile.write(linet+'\n')
dfile.close()
ofile.close()
将转换好格式的txt文件写入一个目录内