【问题标题】:How to open page in browser from html file on disk with user default webrowser? (not IE)如何使用用户默认的 Web 浏览器从磁盘上的 html 文件在浏览器中打开页面? (不是 IE)
【发布时间】:2022-01-06 21:04:13
【问题描述】:

我用过

webbrowser.open('file://page/index.html')

页面是用 IE 打开的。我如何将其更改为用户网络浏览器,例如chrome、opera 和对方?

【问题讨论】:

    标签: python html file web internet-explorer


    【解决方案1】:

    webbrowser.open() 应该调用默认的网络浏览器,不管它是什么。

    如果你想要一个特定的其他浏览器,你可以使用register()注册它,然后结合get()调用open(),例如

    webbrowser.register('chrome',
        None,
        webbrowser.BackgroundBrowser("C://Program Files (x86)//Google//Chrome//Application//chrome.exe"))
    
    webbrowser.get('chrome').open('file://page/index.html')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-16
      • 1970-01-01
      • 2012-08-11
      • 2018-10-19
      • 2015-04-17
      • 2018-05-02
      • 2011-03-11
      相关资源
      最近更新 更多