Py3: decode subprocess output
Martin v. Loewis
martin at v.loewis.de
Wed Nov 3 03:34:19 EDT 2010
> Under Python 3, subprocess.check_output returns a bytestring that
> doesn't parse. Since the CLI program (written in the 1990's) will
> never send Unicode, is there a way to downconvert the bytestring into
> type str so as to emulate Py2.6 behavior?
What do you mean by "that doesn't parse"? Returning a byte string is
*already* emulating 2.6's behaviour: in 2.6, you also get a byte string,
and most likely the very same string.
> Or alternatively, is there a whizbang Py3 method to parse out strings
> delimited by hex? I tried several tricks but it is all beyond my
> skills.
Please understand that there really aren't "hex characters" here. Each
individual character is a byte, i.e. "Sun" == "\x53\x75\x6d". So the
strings you get aren't delimited by a "hex character", but by a "control
character".
That said: how did you try to parse it, and how did that fail?
Regards,
Martin
More information about the Python-list
mailing list