The byte-sequence C3 BE
is the UTF-8 encoded representation of the character U+00FE.
Python 2 handles strings as a sequence of bytes rather than characters. So 'xfe'
is a str
object containing one byte.
In Python 3, strings are sequences of (Unicode) characters. So the code 'xfe'
is a string containing one character. When you print the string, it must be encoded to bytes. Since your environment chose a default encoding of UTF-8, it was encoded accordingly.
How to solve this depends on your data. Is it bytes or characters? If bytes, then change the code to tell the interpreter: print(b'xfe')
. If it is characters, but you wanted a different encoding then encode the string accordingly: print( 'xfe'.encode('latin1') )
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…