JSONの書込み、読込 等 - Python徹底解説
list , dic → JSON str 【dumps】
import json
test_dic = {'key1':'val1', 'key2':2}
json_str = json.dumps(test_dic)
JSON str → list , dic 【loads】
import json
json_str = '{"key1": "val1", "key2": 2}'
test_dic = json.loads(json_str)
list , dic → JSON file 【dump】
import json
import codecs
test_dic = {'key1':'val1', 'key2':2}
with codecs.open('test.json','w+','utf8') as fp:
json.dump(test_dic, fp)
JSON file → list , dic 【load】
import json
import codecs
with codecs.open('test.json','r','utf8') as fp:
test_dic = json.load(fp)
おすすめ記事
COVID-19のRNA/DNAのチェック
エラーメッセージ集 Pandas徹底解説 - Python
Django テンプレート 使用 #2 Staticファイルの使用
Django チーター#1 - Python
Django エラー『TemplateDoesNotExist』対策
全国の町丁目レベル(189,540件)の住所データのオープンデータをPython Pandasで処理してみた
Supponsered
外部サイト
↓プログラムを学んでみたい場合、学習コースなどもおすすめです!