- 经验
- 5
- 分贝
- 0
- 家园分
- 14
- 在线时间:
- 0 小时
- 最后登录:
- 2016-5-17
- 帖子:
- 3
- 精华:
- 0
- 注册时间:
- 2015-5-29
- UID:
- 1124154
注册: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 "
|
|