python中的str對象其實就是"8-bit string" ,字節字符串,本質上類似java中的byte[]。
而python中的unicode對象應該才是等同於java中的String對象,或本質上是java的char[]。
str: s = "你好"
unicode: u = u"你好“
unicode轉化為str,采用encode 編碼:
str = u.encode('gbk')
str轉化為unicode ,采用decode 解碼:
unicode = s.decode('gbk')