Python请求:响应对象不包含';状态';标题
这是请求1.1.0和Python2.6.4(在Python2.7.2上也是相同的行为) 根据文档,应该有一个标题['status']条目,其字符串类似于“200OK” 以下是标题dict的全部内容:Python请求:响应对象不包含';状态';标题,python,http-status-codes,python-requests,Python,Http Status Codes,Python Requests,这是请求1.1.0和Python2.6.4(在Python2.7.2上也是相同的行为) 根据文档,应该有一个标题['status']条目,其字符串类似于“200OK” 以下是标题dict的全部内容: >>> response.headers {'x-xss-protection': '1; mode=block', 'transfer-encoding': 'chunked', 'set-cookie': 'PREF=ID=74b29ee465454efd:FF=0:TM=1
>>> response.headers
{'x-xss-protection': '1; mode=block', 'transfer-encoding': 'chunked', 'set-cookie': 'PREF=ID=74b29ee465454efd:FF=0:TM=1362094463:LM=1362094463:S=Xa96iJQX_9BrC-Vm; expires=Sat, 28-Feb-2015 23:34:23 GMT; path=/; domain=.google.com, NID=67=IH21bLPTK2gLTHCyDCMEs3oN5g1uMV99U4Wsc2YA00AbFt4fQCoywQNEQU0pR6VuaNhhQGFCsqdr0FnWbPcym-pizo0xVuS6WBJ9EOTeSFARpzrsiHh6HNnaQeCnxCSH; expires=Fri, 30-Aug-2013 23:34:23 GMT; path=/; domain=.google.com; HttpOnly', 'expires': '-1', 'server': 'gws', 'cache-control': 'private, max-age=0', 'date': 'Thu, 28 Feb 2013 23:34:23 GMT', 'p3p': 'CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."', 'content-type': 'text/html; charset=ISO-8859-1', 'x-frame-options': 'SAMEORIGIN'}
正是在这里,我想到了这个dict应该包含一个“状态”条目
我做错什么了吗?你在寻找“原因”
custom.php包含:
header("HTTP/1.1 200 Testing")
结果:
>>> x=requests.get("http://apple.adam.gs/custom.php")
>>> print x.reason
Testing
>>>
header("HTTP/1.1 200 Testing")
>>> x=requests.get("http://apple.adam.gs/custom.php")
>>> print x.reason
Testing
>>>