I use Google App Engine and cannot use any C/C++ extension, just pure & pythonic library to do conversion of Unicode/UTF-8 strings to lower/upper case. str.lower() and string.lowercase() don't.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
str
encoded in UTF-8 and unicode
are two different types. Don't use string
, use the appropriate method on the unicode object:
>>> print u'ĉ'.upper()
Ĉ
Decode str
to unicode
before using:
>>> print 'ĉ'.decode('utf-8').upper()
Ĉ