L8: problem with binary data (Python 3)

499 views
Skip to first unread message

Norbert Schlaffke

unread,
Feb 21, 2017, 8:27:12 AM2/21/17
to Python Challenge
I downloaded and isolated the strings using urlib and re. After conversion using bytearray I got this: 
bytearray(b'BZh91AY&SYA\\xaf\\x82\\r\\x00\\x00\\x01\\x01\\x80\\x02\\xc0\\x02\\x00 \\x00!\\x9ah3M\\x07<]\\xc9\\x14\\xe1BA\\x06\\xbe\\x084')
However, I keep getting this error: OSError: Invalid data stream
Thanks for help in advance!

Beniamin Kalinowski

unread,
Jun 28, 2017, 4:22:30 PM6/28/17
to Python Challenge
the 'BZh91AY&SYA\\xaf\\x82\\r\\x00\\x00\\x01\\x01\\x80\\x02\\xc0\\x02\\x00 \\x00!\\x9ah3M\\x07<]\\xc9\\x14\\xe1BA\\x06\\xbe\\x084' is an escaped unicode value, not a byte array.
You should change r"\xaf" string to the b"\xaf" value.
Reply all
Reply to author
Forward
0 new messages