The two data types, str and bytes, are mutually exclusive. One cannot legally combine them into one call. With the distinction between text and data, therefore, comes the need to convert between them.
>>> z = b”Hello World!”
>>> y = “Hello World!”
>>> type(z)
<class ‘bytes’>
>>> type(y)
<class ’str’>
To convert from str to bytes, use str.encode().
>>> [...]
Posts Tagged ‘Data Types’
Convert str to bytes in python
July 5th, 2009 by WEBNESBAY

Posted in
Tags:




































