-
def shell_exec(cmd: str) -> str:
"""
执行终端命令,输出终端打印结果
:param cmd:
:return:
"""
with os.popen(cmd) as fp:
bf = fp._stream.buffer.read()
out = bf.decode().strip()
return out
python执行终端命令并获得输出结果
发布时间 2023-07-01 09:09:20作者: CJTARRR
def shell_exec(cmd: str) -> str:
"""
执行终端命令,输出终端打印结果
:param cmd:
:return:
"""
with os.popen(cmd) as fp:
bf = fp._stream.buffer.read()
out = bf.decode().strip()
return out