最近在寫python with CSV writing 的時候常遇到

UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe5

後來查了網路, 是因為字符问题,解決方法也很單純,加上下面3行即可

import sys
reload(sys)
sys.setdefaultencoding(‘utf-8’)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>