Python2和Python3在编码处理上有哪些差异和问题?
- 内容介绍
- 文章标签
- 相关推荐
本文共计125个文字,预计阅读时间需要1分钟。
Python3中数据类型存储的是str: Unicode 和 bytes: bytes,Python2中数据类型存储的是str: bytes 和 unicode: unicode。Python2中,`print 中国 + u美` 是不能拼接的,而 `print hello + uWorld` 是可以拼接的,因为 Ascii 码以内的可以转换。
Python3数据类型存的是str:Unicode 和bytes:bytes
Python2数据类型存的是str:bytes 和unicode:unicode
python2 : print "中国"+u"美" 是不能拼接的
而 print “hello”+u"World"是可以拼接的,
Ascii码以内的可以转化,对以外的则不能转化;比如中文
python3将Python2中的bytes和Unicode做了详细的区分;
本文共计125个文字,预计阅读时间需要1分钟。
Python3中数据类型存储的是str: Unicode 和 bytes: bytes,Python2中数据类型存储的是str: bytes 和 unicode: unicode。Python2中,`print 中国 + u美` 是不能拼接的,而 `print hello + uWorld` 是可以拼接的,因为 Ascii 码以内的可以转换。
Python3数据类型存的是str:Unicode 和bytes:bytes
Python2数据类型存的是str:bytes 和unicode:unicode
python2 : print "中国"+u"美" 是不能拼接的
而 print “hello”+u"World"是可以拼接的,
Ascii码以内的可以转化,对以外的则不能转化;比如中文
python3将Python2中的bytes和Unicode做了详细的区分;

