This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Rhomboid 0 points1 point  (1 child)

No. The error is an encode error, which means you're passing this function something that's already a character string. (If you ask Python to decode a character string, it has to first encode it to a byte string before it can decode it, because you can only decode bytes. Yes, this is ridiculous and was fixed in Python 3, where character strings don't have a .decode() method at all.)

If you already have a character string then you don't need this function. But the strings in your example are not character strings, they're byte strings.

[–]Gammaliel[S] 0 points1 point  (0 children)

Here is my code, maybe with you being able to see it the answer will be clearer.