Suppose I have something like:
a = \"Gżegżółka\"
a = bytes(a, \'utf-8\')
a = str(a)
which returns string in form:
b\'G\\xc5\\xb
I found it. The simplest way to convert string representation of bytes to bytes again is through the eval
statement:
a = "Gżegżółka"
a = bytes(a, 'utf-8')
a = str(a) #this is the input we deal with
a = eval(a) #that's how we transform a into bytes
a = str(a, 'utf-8') #...and now we convert it into string
print(a)