C114门户论坛百科APPEN| 举报 切换到宽版

亚星游戏官网

 找回密码
 注册

只需一步,快速开始

短信验证,便捷登录

搜索
查看: 3302|回复: 1

[技术讨论] python生成资源管理系统的五级地址 [复制链接]

军衔等级:

亚星游戏官网-yaxin222  新兵

注册:2015-5-292
发表于 2016-5-17 18:28:14 |显示全部楼层
#coding=utf-8
a = open('1.txt','r')
mystr = a.readlines()
#for key in range(0,len(mystr)):
diqu = '吉安市'
xianshi = '安福县'
str2 = mystr[0].split('\t')
xiangzheng = str2[1].strip("\n")
print "num is " + str(len(xiangzheng))
str_out = ""
input_num = 196
for key in range(1,len(mystr)):
    str1 = mystr[key].split('\t')
    str_first = ""
    str_show = ""

    #xiangzheng自带行分格符
    str_first = diqu +  "\t" + xianshi + "\t" + xiangzheng.strip() + "\t"  + str1[1] + "\t"
    str_end = ""

    #for num in range(0,len(str1)):
     #   str_first = str_first[0:len(str_first)-1] + str1[num] + "\t"
        
    if str1[0].find(str1[1])!=-1:
        str_show = str1[0][len(str1[1]):len(str1[0])]
        if len(str_show) > 0:
            str_show = str_show.strip('\n') + '附近'
        else:
            str_show = str_show
    else:
        #print "input is wrong :" + str1[0]
        str_show = str1[0]
  
str_keep = ""
    for num in range(1,input_num + 1):
        str_keep =  str(num)  + '号' + "\t"   
        str_end =   "旁" + "\t" + "\t" + str(num)+ "户" + "\t"  +  "吉安市安福县"+ xiangzheng +  str1[1] + str_show + str_keep  + "吉安" + "\t" + str1[2].strip('\n') + "\t" + "光分路器" + "\t" + "薄覆盖"
        str_out = str_out + str_first.strip('\n') + str_show + str_keep + str_end.strip() + "\n"
a.close()

b = open('2.txt','w+')
b.writelines(str_out)
b.close()
print "input is over "

举报本楼

本帖有 1 个回帖,您需要登录后才能浏览 登录 | 注册
您需要登录后才可以回帖 登录 | 注册 |

手机版|C114 ( 沪ICP备12002291号-1 )|联系大家 |网站地图  

GMT+8, 2024-11-15 15:01 , Processed in 0.349997 second(s), 15 queries , Gzip On.

Copyright © 1999-2023 C114 All Rights Reserved

Discuz Licensed

回顶部
XML 地图 | Sitemap 地图