When using python in Web development, we also encounter the following problem :
SyntaxError: Non-ASCII character '\xe5' in file
What is wrong with your code?
This is simply because the python file is encoded in ASCII by default, while you have Chinese, Japanese, etc in your code . Even if you save your python file in UTF-8, it still does not work in this code.
So how to fix this problem?
Then solution is extremely simple if you know it.
Just add the following line on the top of you code.
# -*- coding: UTF-8 -*-
or
#coding=utf-8
That's it.
Post a Comment