how to remove CMD window after using.system in python

Asked

Viewed 308 times

2

I have a Python 2.7 code that opens a PDF with os.system('meuarquivo.pdf') and it opens right. But when opening the file it also opens an empty CMD window. Is there any way I can close this window or keep it from appearing?

os.system('MeuArquivo.pdf')

My code is completely useless until I close this file. I would like it to open as a common file and not necessarily be tied to the code.

1 answer

1

I figured out how to do.

I can replace os.system() for:

subprocess.Popen([File],shell=True)

So it does not lock the code and does not open the CMD window.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.