json(javascript object notation)이란?
- 데이터 통신 할 때 주로 사용하며 key와 value 쌍으로 이루어진 파일을 말한다.
- 딕셔너리와 유사하다.
- 파이썬에서는 dictionary와 json 파일을 상호 변환 할 수 있다.
import json
import requests
url = "https://jsonplaceholder.typicode.com/"
#json 형태의 문자열로 가져옴
r = requests.get(f"{url}users/1")
# json => dictionary 변환
response_content = json.loads(r.text)
※ 단 서버에서 json형태로 보내줘야 가능하다.
'Python' 카테고리의 다른 글
| [Python] 클래스 생성자(init 함수) (0) | 2023.03.23 |
|---|---|
| [Python] CSV(comma-separated values) 파일 (0) | 2023.03.22 |
| [Python] requests (0) | 2023.03.22 |
| [Python] 정규표현식(regular expression) (0) | 2023.03.22 |
| [Python] 예외처리문(try-except) (0) | 2023.03.22 |