As a trivial demonstration of what I mean, subprocess.communicate()
's stdout
is always a bytes
string.
But:
>>> assert stdout == bytes('{}'.format(stdin), "utf-8"), \
"{} != {}".format(stdout, stdin)
AssertionError: b'\x00' != b'0'
Moreover, if I follow Convert bytes to a Python string,
>>> assert \
stdout.decode("utf-8") == \
bytes('{}'.format(stdin), "utf-8").decode("utf-8"), \
"{} != {}".format(stdout, stdin)
AssertionError: b'\x00' != b'0'
It's trying to convert and compare byte strings, but I can't figure out how to either
turn them into proper bytes
make the strings look the same
In this case, I happen to have the flexibility to read the ord
of the singular char and compare int:0
with int:0
. What else can solve this?