Answers for "remove extension of a string file python"

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 "remove extension of a string file python"

Python Answers by Framework

Browse Popular Code Answers by Language