소스 검색

update py/POST-GET.py.

xdc 5 년 전
부모
커밋
46a994be26
1개의 변경된 파일8개의 추가작업 그리고 0개의 파일을 삭제
  1. 8 0
      py/POST-GET.py

+ 8 - 0
py/POST-GET.py

@@ -17,6 +17,10 @@ def auth_post():
     auth_headers = {
         "Content-Type": "application/json, charset=UTF-8"
     }
+
+#json为dict时,如果不指定content-type,默认为application/json
+#json为str时,如果不指定content-type,默认为application/json
+
     auth_original = requests.request('post', url_auth, json=auth_body, headers=auth_headers)
     access_token_original = auth_original.json()
     access_token = access_token_original['access_token']
@@ -28,6 +32,10 @@ def post_x-www-form():
     init_headers = {'content-type': 'application/x-www-form-urlencoded'}
     init_url = "http://192.1.1.1:8080/init"
     params = {"account_ids":Ids[0]}
+
+#data为dict时,如果不指定content-type,默认为application/x-www-form-urlencoded,相当于普通form表单提交的形式
+#data为str时,如果不指定content-type,默认为text/plain
+
     resp = requests.post(init_url, data=params, headers=init_headers)
     print(resp.text)