osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Old Man Yells At Cloud


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.