我有一个很大的文件,上面有这样几行:
另一个文件包含:
我只想制作一个文件,替换数据.txt第二个字段在用户.txt. 在决赛中,可能是这样的:
我用python编写了以下代码。你知道吗
with open("File", "r") as sources:
lines = sources.readlines()
with open("File", "w") as sources:
for line in lines:
sources.write(re.sub(r'TextToReplace', 'ParameterToReplace', line))
我需要用文件上的第一个字段替换TextToReplace用户.txt参数toreplace是用户.txt. 多次使用30M+参数。你知道吗
就像一个命令sed 's/TextToReplace/ParameterToReplace/" File
如果数据混合在一起,可以使用dict:
^{} command 对这类事情很有用。
假设shell理解Process Substitutions:
相关问题 更多 >
编程相关推荐