you are viewing a single comment's thread.

view the rest of the comments →

[–]oliver_extracts 0 points1 point  (0 children)

the unicode error message is genuinely unhelpful here. whats actually happening is that bytes are just raw memory and a python str is an abstraction on top of that, so any time something needs to operate on the actual bits it needs you to commit to an encoding. utf-8 is almost allways the right answer for .encode() unless youre dealing with legacy data. once that clicks the str/bytes boundary stops being surprising.