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

Why does Go error when trying to marshal this JSON? -

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

python - Pygame. TypeError: 'pygame.Surface' object is not callable -