もっと詳しく

連載目次 # パスを拡張子とそれ以外の部分に分割する from os.path import splitext path = ‘/dir0/dir1/somefile.txt’ root, ext = splitext(path) print(f’root: {root}, ext: {ext}’) # root: /dir0/dir1/somefile, ext: .txt # Pathオブジェクトではparent属性とstem属性を組み合わせる from pathl…