2019-01-16

2019-01-16  本文已影响0人  七姑凉_12b5

往一系列句子中按照一定规则插入一句话

f1=open('newtest.txt','r',encoding='UTF-8')

f2 =open("result.txt",'w',encoding='UTF-8')

print ('Find_content')

lines = []

temp =''

for linein f1.readlines():

tempST = line.strip().split(';')[1]

if tempST!=temp:

shorTrent = tempST

#insert1 = '名字;' + temp + ';你知道短租房都有哪些吗'

#lines.append(insert1 + '\n')

        insert='名字;'+tempST+';你知道短租房都有哪些吗'

        temp=shorTrent

lines.append(insert+'\n')

lines.append(line)

s =''.join(lines)

f2.write(s)

f1.close

上一篇 下一篇

猜你喜欢

热点阅读