subprocess - Execute files in windows with Python -


this question has answer here:

i want make python program execute file in windows. means if try execute .txt file, open default .txt viewer. possible?

i tried subprocess.call, windowserror: [error 193] %1 not valid win32 application. file i'm trying run .png file.

os.startfile("mytext.txt") #open text editor os.startfile("mytext.pdf") #open in pdf viewer os.startfile("mytext.html") #open in webbrowser 

is how should

however

os.startfile("my_prog.py") 

is bad idea because there no way know if python set default open *.py or if texteditor or ide set default open *.py


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -