ゼロからPythonを学んでいく本連載、今回は、Pythonを使ってファイルを読み書きする方法を解説する。そもそもファイルシステムは、OSの基本的な機能の一つだ。Pythonからファイルを扱うには、ファイルを開き、読み書きし、閉じるという手順に沿う必要がある。今回は、特に、日本語のテキスト ...
os.path.join (folder, filename) ensures the path is correct for the system. On Windows, it uses backslashes (reports\summary.txt); on Linux and macOS it uses forward slashes (reports/summary.txt).