I have an emulator what generate byte code. But I cant convert this byte to readable format like string or int. The emulator language is Korean and the bytes are:
b'P\xaf\x01P\xe5\x01$\x008\x00\r\x00H\x00)\x00P\x00!'
My first question is what is b' P meaning? An the second is how to convert it to string or int?
My first question is what is b'P
That simply means that the byte in question can be rendered in whatever your locale is (probably utf8) as 'P', so python is showing you that rather than the raw byte.
How to convert... to int
Something like
[int(x) for x in a]
?
How to convert... to str
In this case you need to know the encoding. It's not utf-8, or utf-16 or utf-32. You'll have to do some digging, but the basic syntax is:
a.decode("encoding")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.