How do you decode an ascii string in python?

How do you decode an ascii string in python?

>>> a = rbx3cdivx3e
>>> a.decode(unicode_escape)
<div>

Also check out some interesting codecs.

With python 3.x, you would adapt Kabie answer to

a = bx3cdivx3e
a.decode(unicode_escape)

or

a = bx3cdivx3e
a.decode(ascii)

both give

>>> a
b<div>

What is b prefix for ?

Bytes literals are always prefixed with b or B; they produce an
instance of the bytes type instead of the str type. They may only
contain ASCII characters; bytes with a numeric value of 128 or greater
must be expressed with escapes.

How do you decode an ascii string in python?

Leave a Reply

Your email address will not be published. Required fields are marked *