How to escape to binary data in python -
i'm playing pythonchallenge level8
i try un , pw directly url
text = urllib.urlopen('http://www.pythonchallenge.com/pc/def/integrity.html').read() un_pat = re.compile('un: \'(.+)\'') compress_un = un_pat.findall(text)[0]
but un should this
un = 'bzh91ay&sya\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3m\x07<]\xc9\x14\xe1ba\x06\xbe\x084'
is there simple way (except write loop myself) convert compress_un un? python offer library this? thanks
>>> compress_un 'bzh91ay&sya\\xaf\\x82\\r\\x00\\x00\\x01\\x01\\x80\\x02\\xc0\\x02\\x00 \\x00!\\x9ah3m\\x07<]\\xc9\\x14\\xe1ba\\x06\\xbe\\x084' >>> compress_un.decode('string_escape') 'bzh91ay&sya\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3m\x07<]\xc9\x14\xe1ba\x06\xbe\x084'
Comments
Post a Comment