Reputation: 147
How can I open a file via Python through its actual application? Not open(filename), but to actually view the file myself on the computer. Can I do it with subprocess.run and use a terminal command? (I'm on windows).
Upvotes: 1
Views: 398
Reputation: 4105
You can probably do it in one of the following ways:
import subprocess
subprocess.run('notepad.exe')
or
import os
os.startfile('textfile.txt')
which will open the textfile with the program associated with txt files.
Upvotes: 1