【发布时间】:2023-01-11 04:27:16
【问题描述】:
你好,我有一个链接和一个文本。我想超链接这个文本。
例如:
我尝试了下面的一个。但它没有以超链接格式添加新的文本链接。
new_test='www.youtube.com/'
hyperlink_format= '<a href=new_test>text of the link</a>'
打印时我得到的输出hyperlink_format
<a href=new_test>text of the link</a>
我的用例是它应该打印
'<a href=www.youtube.com/>text of the link</a>'
我也尝试过使用 `<a href='{}{}'>{}'.format()' 但这需要两个参数,所以不能继续吗?还有其他想法吗? 谢谢!
【问题讨论】:
-
您确实有两个参数:URL 和文本
"<a href='{}'>{}</a>".format("www.youtube.com","text of the link")。 -
你想做什么?如果您想插入指向
<a>标签的链接,请使用f'<a href="https://{new_test}">text of the link</a>' -
不,我每次都提供更改的链接,因此它不应该是动态的
-
你的意思是“它应该是动态的”。