Python 3 how to convert a list of bytes objects to a list of strings?

Chris Angelico rosuav at gmail.com
Fri Aug 28 08:54:05 EDT 2020


On Fri, Aug 28, 2020 at 10:51 PM Chris Green <cl at isbd.net> wrote:
>
> > One possible solution in Python3 is to decode the byte string using an
> > encoding that allows all 256 byte values, so it won't raise any encoding
> > errors, just give your possibly non-sense characters for non-ASCII text.
> >
> But this will simply get some things quite wrong and produce garbage
> won't it?  Whereas Python 2 would simply scramble the odd character.
>

It would. Don't do that. Either keep it as bytes, or decode it using
the correct encoding.

ChrisA


More information about the Python-list mailing list