是否可以在Python脚本中添加链接并打印到终端/控制台上?就像HTML一样;一旦点击,我们将被重定向到URL。(我在Linux上)
<a href="URL">Click Here To Login</a>
是否可以在Python脚本中添加链接并打印到终端/控制台上?就像HTML一样;一旦点击,我们将被重定向到URL。(我在Linux上)
<a href="URL">Click Here To Login</a>
webbrowser
模块来打开链接:import webbrowser
webbrowser.open("http://www.example.com")
这将在新窗口中为您打开链接。
您还可以将文本输出到HTML文件中,并在Web浏览器中打开HTML文件以获取链接:
open("link.html", "w").write('<a href="http://www.example.com"> Link </a>')
print("\x1b]8;;http://example.com/\x1b\\Ctrl+Click here\x1b]8;;\x1b\\")
更多技术细节请点击这里。
是的,这是可能的。这里有一个简单的Python CGI脚本,可以实现您所描述的功能。
print "Content-type: text/html"
print
print """
<html>
<head><title>Sample</title></head>
<body>
<a href='http://google.com'>google</a>
</body></html>
"""
你可以在这里了解更多关于CGI的信息 http://en.wikipedia.org/wiki/Common_Gateway_Interface
print("https://example.com/")
,然后当你点击它时,它会带你去任何网站。在这种情况下,它是 example.com。我知道支持这个功能的一个应用程序是 Replit.com。