I wanna print some links to cmd and directly from cmd open these links by clicking on it. How can I do this?
Sorry, I do not think it is possible by clicking on them but I can tell you you can use this to open some page in the browser:
import webbrowser
url = “http://google.com/“
webbrowser.open(url)
The command line just doesn't support that kind of interaction AFAIk
What you can do is use webbrowser.open
to open a link in your default web browser like this:
import webbrowser
if input('type yes to open in browser').lower() == 'yes':
webbrowser.open(my_link_var)
What's nice about webbrowser.open
is that it is fully cross platform.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.