"convert" string to bytes without changing data (encoding)

Chris Angelico rosuav at gmail.com
Wed Mar 28 05:02:42 EDT 2012


On Wed, Mar 28, 2012 at 7:56 PM, Peter Daum <gator at cs.tu-berlin.de> wrote:
> Hi,
>
> is there any way to convert a string to bytes without
> interpreting the data in any way? Something like:
>
> s='abcde'
> b=bytes(s, "unchanged")

What is a string? It's not a series of bytes. You can't convert it
without encoding those characters into bytes in some way.

ChrisA



More information about the Python-list mailing list