我有一個自定義的HTTP客戶端,我在生產中使用python3.x。 現在我需要爲python2.7完成相同的功能。 我只有與一個語句的問題:httplib.HTTPResponse.read()意外的關鍵字參數'amt'
data = response.read(amt = 10 *1024 *1024)
其中響應由返回:
urllib2.urlopen(request, timeout=timeout)
所以它是類型的
httplib.HTTPResponse
httplib.HTTPResponse.read()
支持AMT下長度的可選參數python2.7。不過,我得到的錯誤:
Traceback (most recent call last):
File "D:\eclipse_workspace\py27\wsdconfirmationserver.py", line 152, in <module>
print(customHttpRequest(url="http://test.com/"))
File "D:\eclipse_workspace\py27\wsdconfirmationserver.py", line 109, in customHttpRequest
data = response.read(amt = 10 *1024 *1024)
TypeError: read() got an unexpected keyword argument 'amt'
現在討人喜歡的事情是,如果我重命名閱讀()在httplib.HTTPResponse此功能並沒有任何失敗,更多的來源,但很明顯,我介紹在其他無數問題碼。 我徘徊爲什麼會發生這種情況...似乎是一個Python中的錯誤,但是......也許是我不明白的東西。感謝您的時間!
請粘貼整個回溯。 – 2012-04-06 13:59:09
謝謝,回溯建議實際上解決了我的困惑,請參閱接受解決方案的評論。 – sanyi 2012-04-10 12:19:09