Tingting Dong

Tingting Dong

QA,抠脚女汉子,热爱一切美好事物的2货处女座...

LinkedIn

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5

two ways to resolve this problem:

1 specific the way you encoding :

#! /usr/bin/env python 
# -*- coding: utf-8 -*- 

s = '中文' 
s.decode('utf-8').encode('gb18030') 

2 change sys.defaultencoding as your file's encoding :

import sys 
reload(sys) 
sys.setdefaultencoding('utf-8') 

str = '中文' 
str.encode('gb18030')


comments powered by