标签:os for 数据 2014 问题 on line python as
有时候会碰到一些错误换行的数据,比如正确数据应该是:
20141010,aaa,bbb,ccc,ddd,eee
20141010,aaa,bbb, ccc,ddd, eee
解决办法:
import re dfile=open('tt.txt','r') lists=[] for line in dfile: m=re.match('2014.+',line) if m: lists.append(line) else: lists[-1]=lists[-1].strip('\n')+line print lists ofile=open('ttt.txt','w') for line in lists: ofile.write(line) dfile.close() ofile.close()
标签:os for 数据 2014 问题 on line python as
原文地址:http://blog.csdn.net/u013055678/article/details/39956473