Open file in default app and exit in Windows
Tim Chase
python.list at tim.thechases.com
Wed Jan 28 11:11:12 EST 2015
On 2015-01-28 07: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)
You can try
import os
filename = 'my file.csv'
os.startfile(filename)
which works on Windows systems. For other platforms, you'd have to
manually spawn either "open" on Macs or "xdg-open" on Linux. Not
sure if there's a similar application on the BSDs.
-tkc
More information about the Python-list
mailing list