"Python JSON 다루기"의 두 판 사이의 차이

(새 문서: ==개요== ;Python JSON 다루기 ;파이썬 JSON 처리 <source lang='python'> import json x = '{"name":"홍길동", "age":88, "hello": true}' y = json.loads(x) print(y) # {'name':...)
 
3번째 줄: 3번째 줄:
;파이썬 JSON 처리
;파이썬 JSON 처리


{{소스헤더|JSON 문자열을 파이썬 딕셔너리로 변환}}
<source lang='python'>
<source lang='python'>
import json
import json
x = '{"name":"홍길동", "age":88, "hello": true}'
x = '{"name":"홍길동", "age":18}'
y = json.loads(x)
y = json.loads(x)
print(y)
print(y)
# {'name': '홍길동', 'age': 88, 'hello': True}
# {'name': '홍길동', 'age': 18, 'hello': True}
print(y['age'])
print(y['age'])
# 88
# 88
</source>
{{소스헤더|파이썬 딕셔너리를 JSON 문자열로 변환}}
<source lang='python'>
import json
x = {"name":"홍길동", "age":18}
y = json.dumps(x)
print(y)
# {'name': '홍길동', 'age': 18}
</source>
</source>



2020년 1월 12일 (일) 14:01 판

1 개요

Python JSON 다루기
파이썬 JSON 처리
JSON 문자열을 파이썬 딕셔너리로 변환
import json
x = '{"name":"홍길동", "age":18}'
y = json.loads(x)
print(y)
# {'name': '홍길동', 'age': 18, 'hello': True}
print(y['age'])
# 88
파이썬 딕셔너리를 JSON 문자열로 변환
import json
x = {"name":"홍길동", "age":18}
y = json.dumps(x)
print(y)
# {'name': '홍길동', 'age': 18}

2 같이 보기

3 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}