【问题标题】:Python webbrowser module sometimes fails to open url in ChromePython webbrowser 模块有时无法在 Chrome 中打开 url
【发布时间】:2013-04-29 01:20:04
【问题描述】:

我在 Mountain Lion 上将 Chrome 配置为我的默认浏览器。

在我的 Python 2.7.4 程序结束时,我有以下内容:

import webbrowser
webbrowser.open('http://example.com')

有时,此命令不会打开标签 as the documentation suggests will happen,而是聚焦 Google Chrome,而不是在新标签中打开 URL。

我什至不确定从哪里开始调试它(至少 Python 端没有错误)。我会很感激一些关于从哪里开始寻找的想法。

【问题讨论】:

    标签: python google-chrome python-webbrowser


    【解决方案1】:

    webbrowser 2.7 源代码中似乎有 Chrome 特定的代码:

    http://hg.python.org/cpython/file/2.7/Lib/webbrowser.py

    但是,当我在计算机上打开 Python 文件时,它运行的是较早版本的 webbrowser.py 源代码,没有 Chrome 特定的标志。

    我用最新代码(来自网站)更新了我系统上的源代码,它在 Chrome 中运行没有任何问题。

    我确信它在 Python 3.3 中也已修复。

    【讨论】:

      猜你喜欢
      • 2017-08-19
      • 1970-01-01
      • 2020-11-25
      • 2022-08-17
      • 2011-11-30
      • 2023-02-08
      • 1970-01-01
      • 2020-01-26
      • 1970-01-01
      相关资源
      最近更新 更多