ファイルパス

毎日Python/こつこつPython

【毎日Python】Pythonでファイルパスからディレクリパス、ファイルパスを取得する方法|os.path.dirname/basename

import os dir = ('./main/sub/test.txt') Pythonで、ファイルのパスからそのファイルがあるディレクトリまでのパスを取得する方法です。使用するのは、Pythonのos.pathモジュールのdirnam...