How to turn a string into a list of integers?

Ian Kelly ian.g.kelly at gmail.com
Fri Sep 5 04:09:01 CEST 2014


On Thu, Sep 4, 2014 at 6:12 PM, Chris Angelico <rosuav at gmail.com> wrote:
> If it's a Unicode string (which is the default in Python 3), all
> Unicode characters will work correctly.

Assuming the library that needs this is expecting codepoints and will
accept integers greater than 255.

> If it's a byte string (the
> default in Python 2), then you can't actually have any Unicode
> characters in it at all, you have bytes; Py2 lets you be a bit sloppy
> with the ASCII range, but technically, you still have bytes, not
> characters..

In that case the library will almost certainly accept it, but could be
expecting a different encoding.



More information about the Python-list mailing list