The way as python2 and python3 handtle the strings and the bytes are different, thus printing a hex string which contains non-ASCII characters in Python3 is different to Python2 does.
Why does it happens and how could I print something in Python3 like Python2 does? (With ASCII characters or UTF-8 it works well if you decode the bytes string)
Python3:
$ python3 -c 'print("\x41\xb3\xde\x41\x42\x43\xad\xde")' |xxd -p
41c2b3c39e414243c2adc39e0a
Python2:
$ python2 -c 'print "\x41\xb3\xde\x41\x42\x43\xad\xde"' |xxd -p
41b3de414243adde0a
\x0a is newline because print adds it.
How could I print "\xb3" in python3? It adds "\xc2\xb3" instead just "\xb3".
$ python3 -c 'print("\xb3")' |xxd
00000000: c2b3 0a ...
$ python2 -c 'print "\xb3"' |xxd
00000000: b30a ..
"\xb3"in Python2 and Python3 are not the same? The closes equivalent to the Python2 thing in Python3 isb"\xb3". So the questions "how do I write"\xb3"to stdout in Python3 as in Python2" and "how do I write the byte value 0xb3 to stdout in Python3" are two different things. In short, do you already have the string literal and want to write that, or do you have the byte value and want to write that?