python2中的unicode()函數在python3中會報錯:


python2中的unicode()函數在python3中會報錯:NameError: name 'unicode' is not defined 

 

There is no such name in Python 3, no. You are trying to run Python 2 code in Python 3. In Python 3, unicode has been renamed to str.

翻譯過來就是:Python 3中沒有這樣的名字,沒有。 您正在嘗試在Python 3中運行Python 2代碼。在Python 3中,unicode已重命名為str。

函數轉換:unicode()到 str()為:

//python2:
unicode(nn,'utf-8')
//python3:
str(nn)

  


 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM