Python Interface Automation--requests 2

Source: Internet
Author: User

#_*_ encoding:utf-8 _*_ImportJSONImportRequests#POST RequestPayload = {"Cindy":"Hello World",           "python":"1078370383"}r= Requests.post ('Http://httpbin.org/post', Data=payload)Print(R.text)#output, data data transfer to form# {#"args": {},#" data": "",#"Files": {},#"form": {#" Cindy": "Hello World",#"python": "1078370383"#   },#"Headers": {#" Accept": "*/*",#"accept-encoding": "gzip, deflate",#" Connection": "Close",#" content-length": "A",#" content-type": "application/x-www-form-urlencoded",#"Host": "httpbin.org",#" user-agent": "python-requests/2.18.4 "#   },#"JSON": null,#" origin": "211.140.31.50",#"url": "Http://httpbin.org/post"# }#convert payload to JSON format, the body of post is JSON typeData_json =json.dumps (payload) R1= Requests.post ('Http://httpbin.org/post', Data=Data_json)Print(R1.text)#output, return the results to data.# {#"args": {},#"Data": "{\" python\ ": \" 1078370383\ ", \" cindy\ ": \" Hello world\ "}",#"Files": {},#"form": {},#"Headers": {#" Accept": "*/*",#"accept-encoding": "gzip, deflate",#" Connection": "Close",#" content-length": " the",#"Host": "httpbin.org",#" user-agent": "python-requests/2.18.4 "#   },#"JSON": {#" Cindy": "Hello World",#"python": "1078370383"#   },#" origin": "211.140.31.50",#"url": "Http://httpbin.org/post"# }

Python interface Automation--requests 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.