在 Python 3 中,我们使用"string".encode()and"string".decode()将 Unicode 字符串转换为字节字符串,或者将字节字符串转换为 Unicode 字符串。
在 Python 2 中,我们有str()and unicode(),我们也可以encode()和decode()to 他们。但是,Python 3 之间有什么区别吗?
在python2中,str是字节字符串,unicode是unicode字符串。但是编码和解码有些傻,详情参考http://nedbatchelder.com/text/unipain.html