#_*_ 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