3

我想通过mac osx上的python代码打开一个url。我正在使用野生动物园。我试过了webbrowser.open(url,new=1,autoraise=True),,,,。 有时,会打开一个新选项卡,有时不会,如果已经打开了四五个选项卡。我想让它适用于所有浏览器,如 safari、chrome 等。webbrowser.open(url)webbrowser.open_new(url)webbrowser.open_new_tab(url)

4

1 回答 1

3

要在上一个答案中添加一些内容......我有同样的问题,但想在 Google Chrome 中打开一个本地(SVG)文件。我找到的解决方案(这里)是

    if platform == "darwin":  # check if on OSX
        file_location = "file:///" + file_location
    webbrowser.get().open(file_location, new=new)

这适用于我在 OSX 10.10.4 上。

于 2015-10-29T23:48:54.457 回答