Answers for "python remove 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
0

python code to remove file extension

import os
print os.path.splitext("sample.txt")[0]
Posted by: Guest on June-26-2020

Code answers related to "python remove extension from filename"

Python Answers by Framework

Browse Popular Code Answers by Language