调用操作系统打开url? [英] Call to operating system to open url?

查看:23
本文介绍了调用操作系统打开url?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用什么来调用操作系统在用户默认使用的任何浏览器中打开 URL?不担心跨操作系统兼容性;如果它在 linux 中工作,那对我来说就足够了!

What can I use to call the OS to open a URL in whatever browser the user has as default? Not worried about cross-OS compatibility; if it works in linux thats enough for me!

推荐答案

这里是如何使用给定的 url 打开用户的默认浏览器:

Here is how to open the user's default browser with a given url:

import webbrowser

webbrowser.open(url[, new=0[, autoraise=True]])

这是有关此功能的文档.它是 Python 标准库的一部分:

Here is the documentation about this functionality. It's part of Python's stdlibs:

http://docs.python.org/library/webbrowser.html

我已在 Linux、Ubuntu 10.10 上成功测试.

I have tested this successfully on Linux, Ubuntu 10.10.

这篇关于调用操作系统打开url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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