-
兼容windows和linux的终端执行函数
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
兼容windows和linux的终端执行函数
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