Is there a (simple) way to launch the Windows default text editor from a Python script, like the webbrowser module?
NOTE: This is a repost of this question but I don't feel like the question is being answered. I need to open Window's default text-editor without it necessarily being a *.txt file being opened. May it be .xml, .html etc.
For example:
I know that:
notepadexec = "C:/Windows/System32/notepad.exe {}".format(myfile)
subprocess.Popen(notepadexec)
will open the file in notepad editor even if myfile
is a html file, but I want Windows default editor to somehow be chosen.
And yes, the following:
os.system("{}".format(myfile))
will open the file in Windows default editor but only if myfile
is a text file. Aaand it will also open the default browser if it's a html file.
Clarifying the question with an example: How do I open a html file for editing purposes with Windows default text-editor in a python script?