how to remove extension from file name in python code example Example: python code to remove file extension import os print os.path.splitext("sample.txt")[0]