In Python 2.x:
- The
str object is just a sequence of bytes. - A
unicode object is a sequence of characters.
Knowing this, it should be easy to choose the right type:
- If you want the character string to use
unicode . - If you want a string encoded in bytes to use
str (in many other languages you would use byte[] ).
In Python 3.x, the str type is a string of characters, as you would expect. You can use bytes if you need a sequence of bytes.
source share