批量前缀和子修订

时间:2017-09-16 15:23:12

标签: html prefix

输入数据:

Text 1
Text 2
Etc...

我想要这样的输出。更喜欢.txt文件

<a target="_blank" href="https://www.website.com/Text 1">Text 1</a>
<a target="_blank" href="https://www.website.com/Text 2">Text 2</a>

前缀是:

<a target="_blank" href="https://www.website.com/"></a>

有人可以帮助我吗?

2 个答案:

答案 0 :(得分:0)

根据您的评论,您需要了解脚本...

e.g。用python你可以做到:

#!python3
inputext = """Text 1
Text 2
Etc..."""

outputext = ''
for line in inputext.split('\n'):
    outputext += "<a target=\"_blank\" href=\"https://www.website.com/" + line + "\">" + line + "</a>\n"
with open('outfilepath.html', 'w') as outfile:
    outfile.write(outputext)

答案 1 :(得分:0)

制作.bat文件(.py需要在同一目录中)

python text.py > text.txt