Last active
August 29, 2015 14:23
-
-
Save diegorocha/3827bb3a5dfd2f25f050 to your computer and use it in GitHub Desktop.
Exemplo de como abrir um arquivo com o aplicativo padrão do Sistema operacional
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
import subprocess | |
def startFile(filepath): | |
if sys.platform.startswith('darwin'): | |
#MacOs | |
subprocess.call(('open', filepath)) | |
elif os.name == 'nt': | |
#Windows | |
os.startfile(filepath) | |
elif os.name == 'posix': | |
#Unix | |
subprocess.call(('xdg-open', filepath)) | |
startFile('Arquivo.pdf') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment