# -*- coding:utf-8 -*- import time start = time.clock() data=open("Data.txt","r") PipeiData=open("PipeiData.txt","r") #目标文件,所有匹配数据产出在该文件中 result=open("result.txt","w") dict={} for k in data: k=k.strip() k=k.split(‘\t‘) k1=k[0]#id k2=k[1]#注册时间 dict[k1]=k2 ‘‘‘ for k,v in dict.iteritems(): print k,v ‘‘‘ for y in PipeiData: y=y.strip() y=y.split(‘\t‘) y1=y[0]#充值ID y2=y[1]#充值金额 y3=y[2]#充值时间 #print y1,y2,y3 if y1 in dict: yy1=y1 yy2=dict[y1]#注册时间 ss=yy2+‘\t‘+yy1+‘\t‘+y2+‘\t‘+y3 result.write(ss+‘\n‘) result.close() print ‘数据匹配完毕‘ end = time.clock() print "运行时长: %f s" % (end - start)
时间: 2024-10-13 15:02:47