Python. How to print text to console as hyperlink?

前端 未结 3 2026
轻奢々
轻奢々 2020-12-07 04:24

I\'m working on a console application. My application uses urwid lib. In some cases, I need to show very long hyperlinks as short text inside table columns. I want to open l

相关标签:
3条回答
  • 2020-12-07 05:13

    This is completely not a Python question, bash itself doesn't recognize links. But some terminal emulators does. As example Gnome terminal recognize link with http://google.com or www.google.com, but not simple google.com. http:// or www indicate what this is link. Probably most other terminal emu will do same but I can't say whih exactly.

    0 讨论(0)
  • 2020-12-07 05:17

    No, some consoles do recognize urls and convert them to a clickable hyperlink. All you can do is make it easy to recognize for console applications by putting a http:// in your url.

    Also see How does bash recognize a link?

    0 讨论(0)
  • 2020-12-07 05:26

    Yes, using some tools, like gNewt or Curses, you could create a button and 'on click' do an action (like open a browser to a given url).

    gNewt : http://gnewt.sourceforge.net/

    nCurses : https://docs.python.org/3.7/library/curses.html

    Otherwise, it's the terminal application that will manage the text you give it, and if it doesn't implement uri's recognition your program won't work as you'd like.

    0 讨论(0)
提交回复
热议问题