Python.如何将文本作为超链接打印到控制台? [英] Python. How to print text to console as hyperlink?

查看:56
本文介绍了Python.如何将文本作为超链接打印到控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个控制台应用程序.我的应用程序使用 urwid 库.在某些情况下,我需要将很长的超链接显示为表格列内的短文本.当我点击列内的文本时,我想在浏览器中打开链接.

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 links in the browser when I click on the text inside the column.

所以,我的问题是:

是否可以将文本作为超链接打印到控制台?

您能否提供一个小示例,说明如何使用 python 将文本打印为超链接?

Can you provide a small example of how to print text as a hyperlink using python?

推荐答案

是的,使用一些工具,比如 gNewt 或 Curses,你可以创建一个按钮并点击"执行一个操作(比如打开浏览器到给定的 url).

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

否则,终端应用程序将管理您提供的文本,如果它不实现 uri 的识别,您的程序将无法如您所愿.

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.

这篇关于Python.如何将文本作为超链接打印到控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆