cmd = subprocess.Popen(shell, stdin=subprocess.PIPE, stderr=subprocess.PIPE,
                               stdout=subprocess.PIPE, universal_newlines=True, shell=True, bufsize=1)
        # 实时输出
        while True:
            line = cmd.stdout.readline()
            if print_flag:
                print(line)
            if subprocess.Popen.poll(cmd) == 0:  # 判断子进程是否结束
                break
        code = cmd.returncode
        return code

标签: shell, python, code, cmd, subprocess, True, PIPE

相关文章推荐

添加新评论,含*的栏目为必填