课程: Python Essential Libraries
今天就学习课程吧!
今天就开通帐号,24,100 门业界名师课程任您挑!
Working with responses
- [Instructor] HTTP transactions consist of a request and a response. In the previous example, we saw how to use the Requests library to perform the first part, issuing the request to a server using either Get or Post. In this example, we'll take a look at how to work with the responses that come back from the server. So let's go ahead and open up the responses_start and first, let's take a look at how to handle different status codes that are returned. So I'm going to make a simple request to the HTTP bin testing endpoint that always returns a 200 Code which means that everything worked. So I'll call requests.get and I'll go ahead and access https://bin.org/status and then 200, and then I'll just print out the response which is in the status_code. So let's go ahead and make sure that works by running the code and sure enough, there is the 200 response, right there. However, as I'm sure you all know things don't always…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。