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') What are the differences between them? Which one should I opt for and why? See Convert bytes to a string in Python 3 for the other way around. Continue reading...