Posts Tagged ‘Byte String’

Convert str to bytes in python

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().
>>> [...]

New Free AT&T Cell Phones for Sale | Thanks to Credit Card Offers, Bank Reviews & Ratings and Cheap Loan