Skip to content

Instantly share code, notes, and snippets.

@diegorocha
Last active August 29, 2015 14:23
Show Gist options
  • Save diegorocha/3827bb3a5dfd2f25f050 to your computer and use it in GitHub Desktop.
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
#!/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