How do I do this in Python 3 (string.join())?
Cameron Simpson
cs at cskk.id.au
Wed Aug 26 22:53:06 EDT 2020
On 26Aug2020 15:09, Chris Green <cl at isbd.net> wrote:
>2QdxY4RzWzUUiLuE at potatochowder.com wrote:
>> Join bytes objects with a byte object:
>>
>> b"\n".join(popmsg[1])
>
>Aaahhh! Thank you (and the other reply).
But note: joining bytes like strings is uncommon, and may indicate that
you should be working in strings to start with. Eg you may want to
convert popmsg from bytes to str and do a str.join anyway. It depends on
exactly what you're dealing with: are you doing text work, or are you
doing "binary data" work?
I know many network protocols are "bytes-as-text, but that is
accomplished by implying an encoding of the text, eg as ASCII, where
characters all fit in single bytes/octets.
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Python-list
mailing list