In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "introduction of the three parameter request methods of Requests". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn the "introduction of the three parameter request methods of Requests".
Request for URL parameters:
Import requests
''
URL Parameters request method: URL parameter
For example: request http://httpbin.org/get?first_name=hello&last_name=word in get mode
''
# params= {"first_name": "hello", "last_name": "word"}
# responds=requests.get ("http://httpbin.org/get",params=params)"
# print (responds.text)
# print (responds.url)
Form parameter request:
''
Form parameter submission, note that only the form data is updated
Content-Type: application/x-www-form-urlencoded
For example: request http://httpbin.org/post in post mode, and the added resources are params= {"first_name": "hello", "last_name": "word"}
''
Params= {"first_name": "hello", "last_name": "word"}
Headers= {"Content-Tpye": "application/x-www-form-urlencoded"}
Responds=requests.post ("http://httpbin.org/post",data=params,headers=headers)"
Print (responds.text)
Print (responds.url)
Print (responds.request)
Json parameter data request
''
Json data is submitted, and data data is updated
Content-Type: application/json
For example: request http://httpbin.org/post in post mode, and the added resources are params= {"first_name": "hello", "last_name": "word"}
''
# Python Learning Communication QQ Group: 778463939
Params= {"first_name": "hello", "last_name": "word"}
Headers= {"Content-Tpye": "application/json"}
Responds=requests.post ("http://httpbin.org/post",json=params,headers=headers)"
Print (responds.text)
Print (responds.url)
Print (responds.request)
Additional topic-- Building URL
Def build_url (URL,endpoint):
Return "/" .join ([URL,endpoint])
Print ("http://httpbin.org","post")) Thank you for your reading, the above is the content of" introduction to the three parameter request methods of Requests ". After the study of this article, I believe you have a deeper understanding of the introduction of the three parameter request methods of Requests, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
# # create a file #! / usr/bin/env python'
© 2024 shulou.com SLNews company. All rights reserved.