In [8]: b=b'hello' In [9]: type(b) Out[9]: builtins.bytes In [10]: s='hello' In [11]: type(s) Out[11]: builtins.str
To convert from str to bytes, use str.encode().:
In [12]: a=str.encode(s) In [13]: type(a) Out[13]: builtins.bytes
To convert from bytes to str, use bytes.decode():
In [14]: c=bytes.decode(a) In [15]: type(c) Out[15]: builtins.str