有没有办法让subprocess.getoutput处理输出无效的UTF-8?如果命令的输出以非UTF-8字符返回,则会引发异常。但是,它似乎不是函数的编码参数。
File "foo.py", line 104, in <module>
OutText = subprocess.getoutput(TheCmd)
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 827, in getoutput
return getstatusoutput(cmd)[1]
. . .
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcc in position 1495: invalid continuation byte