TypeError: str does not support buffer interface [duplicate]

In python 3, bytes strings and unicode strings are now two different types.
Since sockets are not aware of string encodings, they are using raw bytes strings, that have a slightly different interface from unicode strings.

So, now, whenever you have a unicode string that you need to use as a byte string, you need to encode() it. And when you have a byte string, you need to decode it to use it as a regular (python 2.x) string.

Unicode strings are quotes enclosed strings.
Bytes strings are b"" enclosed strings

See What’s new in python 3.0 .

Leave a Comment