所以我正在寻找python中搜索“特定字符串”(相同字符串,多次)并用文本文件中的唯一值替换每个“特定字符串”的最简单方法
OriginalFile.txt:
Location:
Site 1: x=0,y=0
Site 2: x=0,y=0
Site 3: x=0,y=0
Filewithvalues.txt:
x=1
x=2
x=3
下面是我想要的结果文件的样子:
Updatedfile.txt:
Location:
Site 1: x=1,y=0
Site 2: x=2,y=0
Site 3: x=3,y=0
Tags:
您可以创建生成替换的生成器,并在每次进行替换时对其调用
next
:输出:
相关问题 更多 >
编程相关推荐