0
点赞
收藏
分享

微信扫一扫

python 执行shell 并输出

其生 2023-04-16 阅读 81


def __run_shell(self, shell):
        """执行shell并随时打印输出"""
        cmd = subprocess.Popen(shell, stdin=subprocess.PIPE, stderr=sys.stderr, close_fds=True,
                               stdout=sys.stdout, universal_newlines=True, shell=True, bufsize=1)

        cmd.communicate()
        return cmd.returncode

举报

相关推荐

0 条评论