更新时间:2023-09-11 21:57:46
>>> plain_string = "Hi!"
>>> unicode_string = u"Hi!"
>>> type(plain_string), type(unicode_string)
(<type 'str'>, <type 'unicode'>)
^这是字节字符串(plain_string)和unicode字符串之间的区别.
^ This is the difference between a byte string (plain_string) and a unicode string.
>>> s = "Hello!"
>>> u = unicode(s, "utf-8")
^转换为unicode并指定编码.
^ Converting to unicode and specifying the encoding.