■ get 함수에서 params 인자를 사용해 쿼리 문자열 전달하는 방법을 보여준다.
▶ 예제 코드 (PY)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import httpx def printResponse(title, response): print(title ) print(f" response : {response}" ) print(f" response.url : {response.url}" ) print(f" response.headers['content-type'] : {response.headers['content-type']}") print(f" response.encoding : {response.encoding}" ) print(f" response.status_code : {response.status_code}" ) #print(f" response.text : {response.text}" ) print() parameterDictonary = {"key1" : "value1", "key2" : "value2"} response = httpx.get("https://httpbin.org/get", params = parameterDictonary) printResponse("쿼리 문자열 전달", response) """ 쿼리 문자열 전달 response : <Response [200 OK]> response.url : https://httpbin.org/get?key1=value1&key2=value2 response.headers['content-type'] : application/json response.encoding : ascii response.status_code : 200 """ |