我可以使用这个特殊的转义序列在bash中打印超链接:
echo -e '\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n'
结果(我可以点击的链接):
This is a link
现在我想在Python 3.10中生成:
print('\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n')
\e]8;;http://example.com\e\This is a link\e]8;;\e\
print(r'\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n')
\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n
如您所见,转义序列不是由shell解释的.
print('\033[1mYOUR_STRING\033[0m')
YOUR_STRING # <- is actually bold
如何让python正确格式化URL?