LoginSignup
0
3

More than 3 years have passed since last update.

Python #JSON

Posted at

学習メモ・備忘録

JSON

様々なプログラミング言語間でのデータ交換フォーマットになる言語。PythonでもJSONは標準でサポートされているjsonパッケージを用いて扱うことができる。

Pythonデータにエンコード

import json

with open('test.json', 'r') as j:
    data = json.loads(j.read())

JSONファイルに書き込む

import json

data = ['I love', 
        {'language':  {'target': ['Python', 'Java', 'JavaScript']}},
        {'alcohol': {'target': ['Beer', 'Wine', 'Whisky']}}
       ]

with open('test.json', 'w') as j:
    j.write(json.dumps(data)) 
0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3