i have a python script which should invoke a .exe file to get some result. That .exe file is invoking a new windows command prompt(shell) . i dont need any output from the .exe file.
i 'm using os.system('segwin.exe args') in my script where segwin is an executable.
now my question is : i need to stop invoking cmd prompt
kudos to all
sag
Try this (untested):
import subprocess
CREATE_NO_WINDOW = 0x08000000
args = [...]
subprocess.check_call(["segwin.exe"] + args, creationflags=CREATE_NO_WINDOW)
Note that check_call
checks the return code of the launched subprocess and raises an exception if it's nonzero. If you don't want that, use call
instead.
In general, avoid os.system()
and use the subprocess
module whenever possible. os.system()
always starts a shell, which is nonportable unnecessary on most cases.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.