Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1715681
  • 博文数量: 636
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 3950
  • 用 户 组: 普通用户
  • 注册时间: 2014-08-06 21:58
个人简介

博客是我工作的好帮手,遇到困难就来博客找资料

文章分类

全部博文(636)

文章存档

2024年(5)

2022年(2)

2021年(4)

2020年(40)

2019年(4)

2018年(78)

2017年(213)

2016年(41)

2015年(183)

2014年(66)

我的朋友

分类: 系统运维

2018-11-12 21:02:25

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")
阅读(1500) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~