美文网首页
2019-01-16

2019-01-16

作者: 七姑凉_12b5 | 来源:发表于2019-01-16 11:56 被阅读0次

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

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

相关文章

网友评论

      本文标题:2019-01-16

      本文链接:https://www.haomeiwen.com/subject/cfzpdqtx.html