Python webbrowser:如何在Windows下使用Firefox打开svg文件?

时间:2013-04-03 11:40:43

标签: python file browser python-webbrowser

我尝试使用Python的webbrowser模块在​​Windows 7(firefox版本:19.0.2)下使用firefox浏览器打开svg文件:

import webbrowser

chart_path = "C:\\my_file\\mysvg.svg"
browser = webbrowser.get('mozilla')
browser.open(chart_path) 

但是我收到了这个错误:

    browser = webbrowser.get('mozilla')
  File "C:\Python27\lib\webbrowser.py", line 52, in get
    raise Error("could not locate runnable browser")
webbrowser.Error: could not locate runnable browser

这里有什么问题?我也用"firefox"名称试了一下。但我也遇到了类似的错误。

当我这样做时:

print webbrowser._browsers

我明白了:

{'windows-default': [<class 'webbrowser.WindowsDefault'>, None], 'c:\\program files\\internet explorer\\iexplore.exe': [None, <webbrowser.BackgroundBrowser object at 0x02F81B90>]}

0 个答案:

没有答案