this question has answer here:
i'm opening texturepacks game , holding filenames in table, when use os.listdir() returns filenames extensions. there way remove characters after dot marks file extension?
example: change 'body.png'
'body'
or 'head.jpeg'
'head'
thanks!
you want os.path.splitext
. it's useful splitting file extensions out of filenames.
here's example:
>>> import os.path >>> os.path.splitext('body.png') ('body', '.png') >>> os.path.splitext('body.png')[0] 'body'