首页 > 解决方案 > 从 bash 子进程获取 bash 代码日志

问题描述

我正在使用子进程模块 EG 从 python 运行一些 bash 代码

import subprocess
container_logs = 'az container logs --name textgeneratorinference'

subprocess.call([container_logs],shell=True)

从那里我得到一个 0 响应,表示代码已执行,但是当我在终端中运行同样的代码时,我收到一条消息 EG:

Login Succeeded
WARNING! Your password will be stored unencrypted in .
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

我怎样才能把它变成一个python变量?

标签: pythonbash

解决方案


推荐阅读