这是一个创建于 2705 天前的主题,其中的信息可能已经有所发展或是发生改变。
import http.client
conn = http.client.HTTPConnection("www.xxx.com")
conn.request("GET","/")
response = conn.getresponse()
print(response.status, response.reason)
content = response.read()
print(content)
上面的代码是一个简单的请求过程,请问 response = conn.getresponse()这里 response 是怎么成为对象的? conn.getresponse()不是 http.client 的一个方法吗? response = conn.getresponse()这样写可以让 response 成为 http.client 的对象?
3 条回复 • 2017-04-27 18:54:38 +08:00
|
|
1
fingerstyle 2017-04-27 17:56:01 +08:00
已经明白了。。conn.getresponse()返回一个对象。。
|
|
|
2
pimin 2017-04-27 18:41:50 +08:00 via Android
从 C/C++编程的角度你可能明白了 但是在 Python 里,万物皆对象。 那真是极好的,大家都不用担心找不到对象啦
|
|
|
3
sinux 2017-04-27 18:54:38 +08:00
|