Reputation: 105077
I want to turn C:\abc.bmp
into abc.bmp
, or even better, if possible, in abc
. That is easy to do with .NET as there are functions for both goals. Is there anything similar in python?
Upvotes: 1
Views: 266
Reputation: 319601
>>> os.path.basename(r'C:\abc.txt')
'abc.txt'
for basename only:
>>> base, ext = os.path.splitext(os.path.basename(r'C:\abc.txt'))
>>> base
'abc'
Upvotes: 11