Recently Learning machine learning, the above code are some Python code, for Python is just some basic things, just met a low problem, but still record it.
In the Python code there is a Chinese, but I put the #-*-Coding:utf-8-*-This sentence to the third line, so led to appear, such as the following error:
' \xe5 '
1. The solution is as simple as putting the encoded sentence on the first line:
# -*-coding:utf-8-*- # !/usr/bin/python # Filename:tree.py
2. But if the first line is about the Python interpreter, you can also put the encoded phrase on the second line:
# !/usr/bin/python # -*-coding:utf-8-*- # Filename:tree.py
3. Of course, the code of the sentence can also be written in the following style:
# Coding=utf-8
Resources
"1" http://my.oschina.net/panjavay/blog/142682
"2" https://www.python.org/dev/peps/pep-0263/
Python error: Syntaxerror:non-ascii character ' \xe5 ' workaround