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

Grant Edwards grant.b.edwards at gmail.com
Thu Aug 27 16:37:46 EDT 2020


On 2020-08-27, Chris Green <cl at isbd.net> wrote:

>     bbb = [b'aaa', b'bbb', b'ccc']
>     sss = []
>     for i in range(0, 2):
>         sss.append(str(bbb[i])
>
> but that does seem a bit clumsy.  Is there a better way?

sss = [str(s) for s in bbb]

--
Grant



More information about the Python-list mailing list