使い方
参考:
Python でファイルの読み込み、書き込み (作成・追記) | note.nkmk.me
ファイルを読み書きする | Python 3.x ドキュメント [公式]
open
参考:
os.walk
参考:
os.walk | Python 3.x ドキュメント [公式]
__file__
参考:
Python で実行中のファイルの場所 (パス) を取得する __file__ | note.nkmk.me
Find current directory and file’s directory – Stack Overflow
カレントディレクトリを取得する
参考:
Python カレントディレクトリを取得、変更 (移動) | note.nkmk.me
Find current directory and file’s directory – Stack Overflow
JSON ファイルを出力する
UTF-8 エンコードでデータを JSON ファイルとして出力する。
import json with open(path, 'w', encoding="utf-8") as file: json.dump(data, file, indent=4, ensure_ascii=False)
参考:
Python で JSON 出力する際、日本語が文字化けする件 – Qiita
Saving utf-8 texts in json.dumps as UTF8, not as \u escape sequence – Stack Overflow