1. 异常信息:
  • SyntaxError: Non-ASCII character '\xe5' in file a.py on line 9, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
  • 意思为编码错误
  1. 解决方案:
  • 在文件头上加上如下语句:
  • #!/usr/bin/python
  • #-*-coding:utf-8-*-

--以下是真实的案例--

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

import pandas as pd
from operator import delitem
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model.logistic import LogisticRegression
from sklearn.cross_validation import train_test_split
from sklearn.metrics import classification_report, accuracy_score, confusion_matrix
from sklearn.pipeline import Pipeline
from sklearn.grid_search import GridSearchCV

posted on 2016-03-04 14:06  qqhfeng16  阅读(687)  评论(0编辑  收藏  举报