How to insert links in Python

后端 未结 3 984
耶瑟儿~
耶瑟儿~ 2021-01-06 18:39

Is it possible to add links into the Python script and print it out to the terminal/console? Like in HTML; once it was clicked, we will be redirected to the URL. (I\'m on Li

3条回答
  •  醉话见心
    2021-01-06 19:27

    Recently (in 2017) a few terminal emulators (namely iTerm2, GNOME Terminal, and Tilix; hopefully more to follow) have added support for custom hyperlinks.

    Assuming your python app's output goes to such a terminal emulator, you can create ctrl+clickable (cmd+clickable on mac) hyperlinks like this:

    print("\x1b]8;;http://example.com/\aCtrl+Click here\x1b]8;;\a")
    

    Further technical details are here.

提交回复
热议问题