Answers for "python remove . and extension from filename"

0

remove extension from filename python

import os
base=os.path.basename('/root/dir/sub/file.ext')
print(base)
#'file.ext'
print(os.path.splitext(base))
#('file', '.ext')
print(os.path.splitext(base)[0])
#'file'
Posted by: Guest on June-23-2021

Code answers related to "python remove . and extension from filename"

Python Answers by Framework

Browse Popular Code Answers by Language