混淆了
python2 里邊的 str 和 unicode 數(shù)據(jù)類型。
0.
你需要的是讓編碼用實(shí)際編碼而不是 ascii
1.
對(duì)需要 str->unicode 的代碼,可以在前邊寫上
import sys
reload(sys)
sys.setdefaultencoding('utf8')
把 str 編碼由 ascii 改為 utf8 (或 gb18030)
2.
python3 區(qū)分了 unicode str 和 byte arrary,并且默認(rèn)編碼不再是 ascii