あれもPython,これもPython

Pythonメモ※本サイトはアフィリエイトを利用しています

2020-06-12から1日間の記事一覧

Pythonの辞書を様々なファイル形式で保存する

Pythonの辞書{}をファイルなどに永続化する方法は複数あります。 import json d = {'test':1} # jsonファイルとして保存 with open('json.json','w') as f: json.dump(d,f) # json stringとしてテキストファイルに保存 with open('json.txt','w') as f: txt …