I want to adapt a code written for python3 to python2.7 while doing so I am getting errors because of the this two
bytes(some_string, 'UTF-8') and str(some_string, 'UTF-8')
My Question:
Is following a correct way to adapt str(some_string, 'UTF-8')
a = str(some_string)
a = a.encode('UTF-8')
and how to adapt bytes(some_string, 'UTF-8') to python2.7 as bytes are introduced in python3.
string.decode()convert it into unicode. In python 3 normal string is unicode.str(some_string, 'utf-8')can besome_string.decode('utf-8')andbytes(some_string, 'utf-8')can besome_string.encode('utf-8')