往一系列句子中按照一定规则插入一句话
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
网友评论