1.工具类
def read_from_cmd(cmd, decode='utf-8'):
with subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
stdin=subprocess.DEVNULL,
shell=True,
) as stream:
stdout = stream.communicate()[0].decode(decode)
return stdout
2.使用示例:
①:windows获取IP信息
②:windows获取本机谷歌浏览器的安装地址: