繁体   English   中英

如何在Mac OS X上通过python代码打开URL

[英]How to open a url through python code on mac osx

我想通过Mac OS X上的python代码打开一个URL。 我正在使用野生动物园。 我尝试了webbrowser.open(url,new=1,autoraise=True)webbrowser.open(url)webbrowser.open_new(url)webbrowser.open_new_tab(url) 有时,将打开一个新选项卡,如果已经打开了四个选项卡,则有时不会打开。 我想使其在所有浏览器(例如safari,chrome等)中都能正常工作。

要在先前的答案中添加一些内容...我也有同样的问题,但想在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。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM