Today, I have a wonderful problem,
1.r.request.post (URL)
2..print R. Status_code
Actually the first step of the error, because the URL is not correct, according to the truth should be able to go to the second step and then enter 404
Import Requeststry:requests.get ("Http://not.a.real.url/really_not") except Requests.exceptions.ConnectionError as E : Pass>>> Econnectionerror (Maxretryerror ("Httpconnectionpool" (host= ' Not.a.real.url ', port=80): Max retries Exceeded with URL:/really_not (caused by <class ' socket.gaierror ';: [Errno-2] Name or service not known) ",), >& Gt;> E.args (Maxretryerror ("Httpconnectionpool (host= ' Not.a.real.url ', port=80): Max retries exceeded with URL:/ Really_not (caused by <class ' socket.gaierror ';: [Errno-2] Name or service not known) ', '), >>> E.args[0]max Retryerror ("Httpconnectionpool (host= ' Not.a.real.url ', port=80): Max retries exceeded with URL:/really_not (Caused by & Lt;class ' socket.gaierror ': [Errno-2] Name or service not known) ', ' >>> dir (e.args[0]) [' __class__ ', ' __ Delattr__ ', ' __dict__ ', ' __doc__ ', ' __format__ ', ' __getattribute__ ', ' __getitem__ ', ' __getslice__ ', ' __hash__ ', ' __ Init__ ', ' __module__ ', ' __new__ ', ' __reduce__ ', ' __reducE_ex__ ', ' __repr__ ', ' __setattr__ ', ' __setstate__ ', ' __sizeof__ ', ' __str__ ', ' __subclasshook__ ', ' __unicode__ ', ' __ Weakref__ ', ' args ', ' message ', ' pool ', ' reason ', ' url ']>>> e.args[0].reasongaierror ( -2, ' Name ' or ' service not ' kno Wn ') >>> dir (e.args[0].reason) [' __class__ ', ' __delattr__ ', ' __dict__ ', ' __doc__ ', ' __format__ ', ' __ getattribute__ ', ' __getitem__ ', ' __getslice__ ', ' __hash__ ', ' __init__ ', ' __module__ ', ' __new__ ', ' __reduce__ ', ' __ Reduce_ex__ ', ' __repr__ ', ' __setattr__ ', ' __setstate__ ', ' __sizeof__ ', ' __str__ ', ' __subclasshook__ ', ' __unicode__ ', ' __weakref__ ', ' args ', ' errno ', ' filename ', ' message ', ' strerror ']>>> e.args[0].reason.errno-2
Python requests.exceptions.ConnectionError