Description of attributes or methods
An apparent encoding
Encoding method
Okay, fine
Close connection to server
Listen
Returns the content of the response in bytes
CLookies
Returns a cLookiejar object, including c sent from serverHey, lookie
I'm sorry, elapsed
Returns a timedelta object that contains the amount of time that passes between the sending request and the response arrival and can be used to test the response speed. Like r. Erapsed. MicrosecoNds indicates how many microseconds it takes to respond。
Encoding
Decoding r. Text encoding
The headers
Return response header, dictionary format
Oh, dear
Returns the list of responding objects (url) containing the requested history
Is person reddirect
If the response is permanently redirected url, return true, otherwise return false
"is reddirect
If the response is redirected, return true, otherwise return false
Oh, iter coNent()
An iterative response
Iter lines()
Lines for an iterative response
Json()

Returns the result of the json object (results need to be in json format, otherwise they cause errors)
I'll..Inks
Returns the parsing header link of the response
Next
Returns the requested preparedrequest object next in the reorientation chain
Okay
Check the value of "status code" and return true, if less than 400, or false
Raise for status()
If an error occurs, the method returns an httperror object
Oh, dear
The description of the response status, like "not found" or "ok"
Oh, dear
Returns the person requesting this response
Status code
Returns the status code for http, e. G. 404 and 200 (200 is ok, 404 is not found)
Text
Returns response content, uncode type data
Url
Returns the responding url
The output is as follows:
200. Okay. Utf-8
Request json data file, return json content:
The output is as follows:
{`name': 'web site', 'num': 3, 'sites':[`name': 'google', 'info':['android', 'google search', 'google translation'}, {`name': 'runob', 'info': [`runob', 'info'], ["the tools of the rookies', 'books'], }, {name': 'taobao', 'info': }
Lists method

Lists the following methods:
Methodology description
Delete
Send delete request to specified url
Get it
Send get request to specified url
Head (url,args)
Send head request to specified url
Watch
Send patch request to specified url
Post
Send post request to specified url
Put it down
Send put request to specified url
I'm going to ask you something
Send specified request method to specified url
Send request with request. Request()
The output is as follows:
200
Set the header of the request:
Examples
# import requests packages
II'm sorry
Kw = {'s':'python '}
# set the header of the request

== sync, corrected by elderman == @elder man
#params receives query parameters for a dictionary or string, dictionaries type automatically converted to url code, without urlencode()
Respo= rests. Get ("https://www. Runoob. Com/," params = kw, heads = heads)
# view response status code
I don't know
# view response head character encoding
(response. Encoding)
# view full url
Right
# view response content, response. Text returns data in unicode format
Principal (response. Text)
The output is as follows:
200. Utf-8 https://www. Runoob. Com/? S=python+%e6%95%99%e7%a8%b the rest...
Post() method to send post requests to specified url, in general format as follows:
{\bord0\shad0\alphah3d}requests. Post
The output is as follows:
This content is requested using the post method。
Request time: 2022-05-26:17:30:47
Post requested with parameters:
The output is as follows:
Hello, runob boy. How was your day
Additional request parameters
Send the request by adding additional parameters to the request, such as header, search parameters, request body, etc., such as:
# set request head
params = {'key1': 'value1', 'key2': 'value2'}# set query parameters
data = {`username': 'example', 'password': '123456'}# setup request body
respo= rests. Post
The above code sends a post request with a header, query parameters and request body。
In addition to the basic get and post requests, other http methods such as put, delete, head, options etc. Are supported。




