I have the string x = \'0x32\' and would like to turn it into y = \'\\x32\'. Note that len(x) == 4 and len(y) == 1.>
x = \'0x32\'
y = \'\\x32\'
len(x) == 4
len(y) == 1
Try this:
z = x[2:].decode('hex')