← Go Back

How to Open a File With Its Default Program

On Windows systems, Python provides the standard os.startfile() function.

from os import startfile

# Launch file.txt (probably with notepad)
startfile("file.txt")

The path passed as argument can be relative (as is the example) or absolute.

files windows


🐍 You might also find interesting: