更新时间:2022-06-24 22:31:30
使用 Unicode字符串 :
# Encoding: UTF-8
japanese = u"桜の花びらたち"
print japanese
print len(japanese)
请注意字符串前面的u
.
要将字节字符串转换为Unicode,请使用decode
:"桜の花びらたち".decode('utf-8')
To convert a bytestring into Unicode, use decode
: "桜の花びらたち".decode('utf-8')