Wednesday, September 14, 2011

Solve the UnicodeError: ASCII Decoding/Encoding Error in Python

Sometimes we will get the Unicode Error in python, which means you are try to encode or decode a string which is not encoded in ASCII. ASCII is python default encoding, and what we need to do is just overwriting it to utf-8.
Put following codes in and put this file in your PYTHONPATH, which means it can be imported. This file may already exists somewhere in your PYTHONPATH, if so, just append the following codes in it. The file is a special file which is automatically imported when python restarts.
# this file can be anywhere in your Python path
import sys

No comments:

Post a Comment