To convert Unicode string to bytes object, you can use two methods:
'hello'.encode('utf-8')
bytes('hello', encoding='utf-8')
To convert bytes back to Unicode string, you can use two methods:
b'\xe4\xbd\xa0\xe5\xa5\xbd'.decode('utf-8')
str(b'\xe4\xbd\xa0\xe5\xa5\xbd', encoding='utf-8')
Thanks