The Python Oracle

Best way to convert string to bytes in Python 3?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Lost Meadow

--

Chapters
00:00 Question
00:28 Accepted answer (Score 828)
02:46 Answer 2 (Score 646)
03:09 Answer 3 (Score 263)
04:25 Answer 4 (Score 62)
05:08 Thank you

--

Full question
https://stackoverflow.com/questions/7585...

Question links:
[TypeError: 'str' does not support the buffer interface]: https://stackoverflow.com/questions/5471...

Accepted answer links:
[bytearray]: https://docs.python.org/3/library/functi...
[PyUnicode_AsEncodedString]: http://hg.python.org/cpython/file/5a1241...

Answer 3 links:
[encode]: https://docs.python.org/3/library/stdtyp...

Answer 4 links:
[Python Specific Encodings]: https://docs.python.org/3/library/codecs...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #string #characterencoding #python3x

#avk47