混淆了 python2 裡邊的 str 和 unicode 資料型別。
1.
對需要 str->unicode 的程式碼,可以在前邊寫上
import sys
reload(sys)
sys.setdefaultencoding('utf8')
把 str 編碼由 ascii 改為 utf8 (或 gb18030)
2.
python3 區分了 unicode str 和 byte arrary,並且預設編碼不再是 ascii
混淆了 python2 裡邊的 str 和 unicode 資料型別。
1.
對需要 str->unicode 的程式碼,可以在前邊寫上
import sys
reload(sys)
sys.setdefaultencoding('utf8')
把 str 編碼由 ascii 改為 utf8 (或 gb18030)
2.
python3 區分了 unicode str 和 byte arrary,並且預設編碼不再是 ascii