Urgent: "\" in strings?
Ruud de Rooij
* at spam.ruud.org
Tue Aug 8 06:05:04 EDT 2000
Nick Bower <bowern at ses.curtin.edu.au> writes:
> I'm messing with PIL, and the only way I can see to get a palette out of
> an image returns a string such as:
>
> '\000\000\001\002' etc
>
> which is not that weird until you do a s[0] and it returns:
>
> '\000' instead of '\
>
> How do I convert this string to numbers?
Those \000 indicate characters with a value outside the printable
ASCII range. So '\000' is a single character with the ASCII value
0.
ord(s[0]) is probably what you are looking for to convert them to
numbers.
- Ruud de Rooij.
--
ruud de rooij | *@spam.ruud.org | http://ruud.org
More information about the Python-list
mailing list