import urllib.request
html = urllib.request.urlopen('http://jshawl.com/python-playground/')
s = html.read
print(s)
这是我得到的错误:
<bound method HTTPResponse.read of <http.client.HTTPResponse object at 0x032B18D0>>
如何修复此错误?我犯了什么错误?
最佳答案
您看到的打印内容不是错误 - 您看到的是 HTTPResponse
实例方法字符串表示。要获取方法返回的内容,您应该调用它:
s = html.read()
关于Python3(Urllib) -<绑定(bind)方法 HTTPResponse.read of <http.client.HTTPResponse object at 0x03281BD0>>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36515264/