I've searched many websites, stackoverflow's replies, but have not found exact solution with my trouble, in example:
- When creating bytes with "b" prefix before string, what encoding does python use?
- How to encode string to bytes in python?
My example – I can't understand what encoding will give same result as phrase preceded by with 'b' on escaped string:
>>> txt_bz = b'BZh91AY&SY^\x85\xab\xd2\x00\x00\x00\x81\x80\x02\x02\x1c \x000\xc0\x08a\xa5\x1a\x03\x0b\xb9"\x9c(H/B\xd5\xe9\x00'
>>> txt_cmp = bytes('BZh91AY&SY^\x85\xab\xd2\x00\x00\x00\x81\x80\x02\x02\x1c \x000\xc0\x08a\xa5\x1a\x03\x0b\xb9"\x9c(H/B\xd5\xe9\x00', 'utf-8')
>>> txt_cmp==txt_bz
False
>> txt_cmp = bytes('BZh91AY&SY^\x85\xab\xd2\x00\x00\x00\x81\x80\x02\x02\x1c \x000\xc0\x08a\xa5\x1a\x03\x0b\xb9"\x9c(H/B\xd5\xe9\x00', 'unicode-escape')
>>> txt_cmp==txt_bz
False