When I first started messing around with python strings and unicode, It took me awhile to understand the jargon of decode and encode too, so here's my post from here that may help:
Think of decoding as what you do to go from a regular bytestring to unicode and encoding as what you do to get back from unicode. In other words:
You de - code a str
to produce a unicode
string
and en - code a unicode
string to produce an str
.
So:
unicode_char = u'xb0'
encodedchar = unicode_char.encode('utf-8')
encodedchar
will contain your unicode character, displayed in the selected encoding (in this case, utf-8
).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…