注册 登录
编程论坛 Python论坛

(求助)这句含“Popen”的语句是什么意思?

xiaoyuer_che 发布于 2009-09-24 17:12, 1648 次点击
Popen(cmd, shell = True, stdout = PIPE).communicate()
f = Popen(cmd, shell = True, stdout = PIPE).stdout

刚接触python,不太了解Popen的用法,在网上也搜索不到。麻烦解释一下上面两句。如果有相关的资料推荐,那就更好了!
3 回复
#2
gengwenbin2009-09-25 17:11
没用过这个函数。。。

#3
xmnathan2009-10-19 19:05
管道
很少用到
我的理解是类似水管里不停的往外输出数据,当外部需要调用这些输出数据的时候只要开启一个子进程读取这些数据就可以了
#4
abc_echo2010-03-29 22:20
import os然后查找popen

popen(...)
        popen(command [, mode='r' [, bufsize]]) -> pipe
        
        Open a pipe to/from a command returning a file object.
   
    popen2(cmd, mode='t', bufsize=-1)
        Execute the shell command 'cmd' in a sub-process.  On UNIX, 'cmd'
        may be a sequence, in which case arguments will be passed directly to
        the program without shell intervention (as with os.spawnv()).  If 'cmd'
        is a string it will be passed to the shell (as with os.system()). If
        'bufsize' is specified, it sets the buffer size for the I/O pipes.  The
        file objects (child_stdin, child_stdout) are returned.
   
    popen3(cmd, mode='t', bufsize=-1)
        Execute the shell command 'cmd' in a sub-process.  On UNIX, 'cmd'
        may be a sequence, in which case arguments will be passed directly to
        the program without shell intervention (as with os.spawnv()).  If 'cmd'
        is a string it will be passed to the shell (as with os.system()). If
        'bufsize' is specified, it sets the buffer size for the I/O pipes.  The
        file objects (child_stdin, child_stdout, child_stderr) are returned.
   
    popen4(cmd, mode='t', bufsize=-1)
        Execute the shell command 'cmd' in a sub-process.  On UNIX, 'cmd'
        may be a sequence, in which case arguments will be passed directly to
        the program without shell intervention (as with os.spawnv()).  If 'cmd'
        is a string it will be passed to the shell (as with os.system()). If
        'bufsize' is specified, it sets the buffer size for the I/O pipes.  The
        file objects (child_stdin, child_stdout_stderr) are returned.
1