64.
base64:
>>> import base64
>>> base64.b64encode(b"\x80\xFF")
b'gP8='
, b Python, .
b.
, py2 py3.
import base64
x = 'gP8='
base64.b64decode(x.encode("latin1"))
gives you str '\x80\xff'in 2.6 (should work in 2.5) and b'\x80\xff'in 3.x.
As an alternative to the two above steps, you can do the same with hexadecimal data, you can do
import binascii
x = '80FF'
binascii.unhexlify(x)
source
share