我使用Google App Engine,无法使用任何C/C++扩展,只需pure&pythonic库即可将Unicode/UTF-8字符串转换为小写/大写。str.lower()和string。小写()不要。

有帮助吗?

解决方案

str 编码为UTF-8和 unicode 是两种不同的类型。不要使用 string, ,在unicode对象上使用适当的方法:

>>> print u'ĉ'.upper()
Ĉ

解码/解码 strunicode 使用前:

>>> print 'ĉ'.decode('utf-8').upper()
Ĉ
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top