簡體   English   中英

從 `urllib2.urlopen` 獲取錯誤文本

[英]Getting the error text from `urllib2.urlopen`

我使用 Python 的urllib2.urlopen並從服務器收到 500 錯誤。 如何找到錯誤的文本? 我希望它有有用的信息。

from urllib2 import urlopen, HTTPError

try:
    f = urlopen(url)
except HTTPError, e:
    print(e.read())

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM