问题
在平时工作中,遇到了这样的错误:
UnicodeDecodeError: 'ascii' codec can't decode byte
想必大家也都碰到过,很常见 。于是决定对python的编码做一个整理和学习。
基础知识
在python2.x中,有两种数据类型,unicode和str,这两个都是basestring的子类
>>> a = '中'
>>> type(a)
<type>
>>> isinstance(a,basestring)
True
>>> a = u'中'
>>> type(a)
<type>
>>> isinstance(a,