【发布时间】:2023-04-04 09:06:01
【问题描述】:
我有以下文本文件:
c:/users/desktop
c:/users/test
c:/users/etc
....
文本文件中的每一行都有一个字符串。我想修改文件,使每一行都有两个字符串。应该是这样的:
c:/users/desktop c:/users/desktop
c:/users/test c:/users/test
c:/users/etc c:/users/etc
....
在此之后,我想更改每行中的第二个字符串,使其成为一条新路径。有一个固定的NEW_PATH,其中包含必须插入的部分。修改后是这样的:
c:/users/desktop f:/etc/rel/users/desktop
c:/users/test f:/etc/rel/users/test
c:/users/etc f:/etc/rel/users/etc
我正在尝试将其保存在输出文件 tocopy.txt。
如何做到这一点?
【问题讨论】: