'gbk' codec can't decode byte 0x82 in position 8: incomplete multibyte sequence

class CityDict(models.Model):
    name = models.CharField(max_length=20, verbose_name=u"城市")
    desc = models.CharField(max_length=200, verbose_name=u"描述")
    add_time = models.DateTimeField(default=datetime.now, verbose_name="添加时间")

    class Meta:
        verbose_name = u"城市"
        verbose_name_plural = verbose_name

    def __unicode__(self):
        return self.name

在model内使用
def _unicode_(self):
return self.name
时报错‘gbk’ codec can’t decode byte 0x82 in position 8: incomplete multibyte sequence

编码问题,在python2.7内出现编码问题太常见了,
哪里出错copy到哪里,一般都能解决,如果解决不了,再想办法

import sys
reload(sys)
sys.setdefaultencoding('utf8')

你可能感兴趣的:(python错误)