Strings
Terry Reedy
tjreedy at udel.edu
Thu Apr 21 18:47:19 EDT 2005
"Dan" <dan at dontspammecauseidontlikit.com> wrote in message
news:5s9f61t9o5iv2qa5vccq3757djq0e0usor at 4ax.com...
> I've having trouble coming to grip with Python strings.
>
> I need to send binary data over a socket. I'm taking the data from a
> database. When I extract it, non-printable characters come out as a
> backslash followed by a three numeric characters representing the
> numeric value of the data.
Are you sure that the printable expansion is actually in the string itself,
and not just occurring when you 'look' at the string by printing it -- as
in...
>>> s='1\001b'
>>> s
'1\x01b'
>>> len(s)
3
?
> I guess this is what you would call a raw Python string.
No such thing. There are only strings (and unicode strings). 'raw' only
applies to a mode of interpreting string literals in the process of turning
them into bytes or unicode.
Terry J. Reedy
More information about the Python-list
mailing list