【问题标题】:Getting the error text from `urllib2.urlopen`从 `urllib2.urlopen` 获取错误文本
【发布时间】:2011-09-02 17:05:15
【问题描述】:

我使用 Python 的 urllib2.urlopen 并从服务器收到 500 错误。如何找到错误的文本?我希望它有有用的信息。

【问题讨论】:

    标签: python http urlopen


    【解决方案1】:
    from urllib2 import urlopen, HTTPError
    
    try:
        f = urlopen(url)
    except HTTPError, e:
        print(e.read())
    

    【讨论】:

      猜你喜欢
      • 2023-03-18
      • 2018-01-26
      • 2010-10-25
      • 1970-01-01
      • 1970-01-01
      • 2015-06-25
      • 1970-01-01
      • 2012-04-13
      • 1970-01-01
      相关资源
      最近更新 更多