Open file in default app and exit in Windows

Tim Golden mail at timgolden.me.uk
Wed Jan 28 11:07:04 EST 2015


On 28/01/2015 15:50, stephen.boulet at gmail.com wrote:
> I am using the following to open a file in its default application in
> Windows 7:
> 
> from subprocess import call
> 
> filename = 'my file.csv' call('"%s"' % filename, shell=True)
> 
> This still leaves a python process hanging around until the launched
> app is closed. Any idea how to get around?
> 

This is somewhat clumsy. The built-in way is:

import os
os.startfile("my file.csv")

TJG



More information about the Python-list mailing list