728x90
Python에서 JSON 변환하자.
1. 문자열 : dumps / loads
2. 파일 : dump / load
※ 소스
import json
json1 = {"변수명":"변수값"}
str1 = json.dumps(json1) # json -> string
str2 = json.dumps(json1, ensure_ascii=False) # json -> string
print(str1)
json2 = json.loads(str1) # string -> json
print(json2)
실행
728x90
반응형
'Software > Python' 카테고리의 다른 글
Python 시작하기 - selenium 활용 (0) | 2024.07.02 |
---|---|
Python 시작하기 - selenium 소개 (0) | 2024.07.02 |
Python 시작하기 - CSV 저장 (0) | 2024.06.23 |
Python 시작하기 - Mysql 조회 (0) | 2024.06.23 |
Python 시작하기 - CSV읽기 및 JSON변환 (0) | 2024.06.23 |