def writeLog(txtname, contests):
f = file("/home/haoren/guojia/shanghai/%s" %txtname,'a+')
f.write(contests)
f.close()
return
alldata = []
fd = open('/home/haoren/guojia/shanghai/shuju6.txt', 'r')
file1 = "shuju666.txt"
for line in fd:
line2 = line.strip()
duid = line2.split(',')[0]
duhao = line2.split(',')[1]
duid1 = line2.split(',')[2]
shou = line2.split(',')[3]
mian = line2.split(',')[4]
duid2 = line2.split(',')[5]
nicheng = line2.split(',')[6]
#构造元祖
data = (str(duid),str(duhao),str(duid1),str(shou),str(mian),str(duid2),str(nicheng)) alldata.append(data)
alldata1 = sorted(alldata, key=lambda alldata: int(alldata[4]) ,reverse = True)
for t in alldata1:
t = ','.join(t)
writeLog(file1,str(t))
writeLog(file1,"\r\n")
阅读(1547) | 评论(0) | 转发(0) |