os.popen()

os.popen()功能强于os.system(),os.popen()可以返回回显的内容,以文件描述符返回。eg:

 

1 #!/usr/bin/env python
2 # -*- coding: UTF-8 -*-
3 
4 import os
5 
6 test = os.popen("ping www.baidu.com")
7 print test.read()

 

 

 

posted @ 2013-05-06 18:20  烤串的_  阅读(201)  评论(0编辑  收藏  举报