Answers for "path module get filename"

33

python get filename from path

import os
print(os.path.basename(your_path))
Posted by: Guest on February-28-2020
-1

what does filename = path(file).stem python

from pathlib import Path

Path('/root/dir/sub/file.ext').stem

# returns 'file'
Posted by: Guest on June-03-2020

Python Answers by Framework

Browse Popular Code Answers by Language