python运行命令行的输出结果,并处理中文乱码

res = os.popen("cmd命令")
tempstream = res._stream

print(tempstream.buffer.read().decode(encoding='utf-8'))

s = tempstream.buffer.read().decode(encoding='utf-8')
之后得到就是字符串了,可以正则取我们的结果

posted @ 2020-04-20 10:32  阿磊小哥哥呀  阅读(1557)  评论(0编辑  收藏  举报