TypeError: ‘str’ does not support the buffer interface suggests two possible methods to convert a string to bytes:

b = bytes(mystring, 'utf-8')

b = mystring.encode('utf-8')

Which method is more Pythonic?

5

Leave a Reply

Your email address will not be published. Required fields are marked *