开发者

Python making cmd invisible when using the os.system

I found out that i could ping a system on python by typing

os.system('ping ip')

but whe开发者_Go百科n i execute it, it shows cmd.

My question is, how do i ping someone on python without showing the cmd?


If you need only a ping, then it would be better to use something like ping.py.

In other cases use subprocess as suggested by @Sentinel


Look at the

http://docs.python.org/library/subprocess.html

module.

It gives you enough options for controlling the output.

Or use standard bash redirection in order to send the output to /dev/null


See my answer to hiding console when run in os.startfile()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜