반응형
dictionary 를 json 으로 변환
https://docs.python.org/2/library/json.html
18.2. json — JSON encoder and decoder — Python 2.7.18 documentation
18.2. json — JSON encoder and decoder JSON (JavaScript Object Notation), specified by RFC 7159 (which obsoletes RFC 4627) and by ECMA-404, is a lightweight data interchange format inspired by JavaScript object literal syntax (although it is not a strict
docs.python.org
import json
dict1 = { 'name' : 'song', 'age' : 10 }
print "dict1 = %s" % dict1
print "dict1 type = %s" % type(dict1)
print "================"
# CONVERT dictionary to json using json.dump
json_val = json.dumps(dict1)
print "json_val = %s" % json_val
print "json_val type = %s" % type(json_val)
반응형
'프로그래밍 > Python' 카테고리의 다른 글
[python] jupyter notebook 설치 & 구동 (0) | 2022.04.07 |
---|---|
[python] 초보자를 위한 파이썬 300제 (0) | 2022.04.07 |
[python] pandas 결과값을 csv 파일 형식으로 누적해서 저장하기: to_csv (0) | 2022.04.05 |
[python] 웹 크롤링 준비 - Beautifulsoup4, reqeusts, urllib3 (0) | 2022.04.04 |
[python] 이런 에러시 " Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found " (0) | 2022.03.21 |