TIL

Today I Learned. 知ったこと、学んだことを書いていく

辞書からJSON形式へ変換 - Python

辞書型からJSON形式のデータに変換するときにはjson.dumps()を使う
また、JSON形式のテキストデータになる!(JSONはテキストの形式だから当たり前か...)

>>> import json
>>> testDict = {
...     'one': 1,
...     'two': 2,
... }
>>> json.dumps(testDict)
'{"one": 1, "two": 2}'
>>> type(json.dumps(testDict))
<class 'str'>

参考文献

【Python入門】JSON形式データの扱い方 - Qiita