在 2017年5月5日星期五 UTC+8下午6:02:04,程淼写道:
> here is the client use get 
> ------------------------------------------------------------------
> import json 
> import requests 
> 
> url = "http://abc.com:11/ip"; 
> auth = {"ip":["10.100.1.1","10.100.1.2"], 
>          "time": "20170504133025" 
>         } 
> 
> try: 
>     req = requests.get(url,params=auth)     
> 
> except requests.exceptions.ConnectionError,e: 
>     print e 
> else: 
>     print req 
>     print req.headers 
>     print req.text 
> ------------------------------------------------------------------
> 
> but not work for post 
> ------------------------------------------------------------------
> import json 
> import requests 
> 
> url = "http://abc.com:11/ip"; 
> auth = {"ip":["10.100.1.1","10.100.1.2"], 
>          "time": "20170504133025" 
>         } 
> 
> try: 
>     headers = {'Content-Type': 'application/json'} 
>     req = requests.post(url=url,data=json.dumps(auth),headers=headers) 
> 
> except requests.exceptions.ConnectionError,e: 
>     print e 
> else: 
>     print req 
>     print req.headers 
>     print req.text 
> ------------------------------------------------------------------
> arguments always get FieldStorage(None, None, []) 
> 
> 
> and i use other post way, it works. 
> ------------------------------------------------------------------
> <!DOCTYPE html> 
> <html><head><title>login</title></head> 
> <body> 
> <form action="http://abc.com:11/ip/"; method="post"> 
> <input type="text" name="ip"/> 
> <input type="text" name="time"/> 
> <input type="submit"/> 
> </form> 
> </body> 
> </html> 
> ------------------------------------------------------------------
> 
> is this any problem requests.post(python) with cgi.FieldStorage ? 
> 
> 
> Thanks
Server : Apache/2.4.10 (Debian)
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to