Old Man Yells At Cloud

Steve D'Aprano steve+python at pearwood.info
Sun Sep 17 07:25:21 EDT 2017


On Sun, 17 Sep 2017 08:03 pm, Leam Hall wrote:

> I'm still trying to figure out how to convert a string to unicode in
> Python 2.


A Python 2 string is a string of bytes, so you need to know what encoding they
are in. Let's assume you got them from a source using UTF-8. Then you would do:

mystring.decode('utf-8')

and it will return a Unicode string of "code points" (think: more or less
characters).



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list