Код: Выделить всё
var = u' \u2013 2'
Код: Выделить всё
var.decode('utf-8')
Код: Выделить всё
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in position 7: ordinal not in range(128)
Код: Выделить всё
var.encode('utf-8')
Код: Выделить всё
'ascii' codec can't decode byte 0xe2 in position 8: ordinal not in range(128)
Код: Выделить всё
sys.setdefaultencoding('utf-8')
Подробнее здесь: https://stackoverflow.com/questions/303 ... code-issue
Мобильная версия