File extensions are used to point the kind of file, equivalent to .txt for textual content information or .py for Python scripts. Checking the file extension may be helpful for figuring out the way to course of the file or what program to open it with.
In Python, there are a number of methods to test the file extension of a file. A technique is to make use of the os.path.splitext() perform. This perform takes a file path as enter and returns a tuple containing the file identify and the file extension. For instance: