码迷,mamicode.com
首页 > 编程语言 > 详细

python出现Non-ASCII character '\xe7' in file ex6.py on line 1, but no encoding declare错误

时间:2015-04-23 13:33:07      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:python   python教程   python开发视频   python教学视频   python语言   

今天在学习python编程的时候出现了这个错误提示,原文如下:

/Users/mac/python/mac/bin/python /Users/mac/Desktop/3333/3333.py
  File "/Users/mac/Desktop/3333/3333.py", line 8
SyntaxError: Non-ASCII character ‘\xe4‘ in file /Users/mac/Desktop/3333/3333.py on line 8, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
Process finished with exit code 1


当时不知所措呀,后来在网站找到的解决方法有三种:

一、在文件头部添加如下注释码:

 # coding=<encoding name> 例如,可添加# coding=utf-8

二、在文件头部添加如下两行注释码:

#!/usr/bin/python

# -*- coding: <encoding name> -*- 例如,可添加# -*- coding: utf-8 -*-

三、在文件头部添加如下两行注释码:

 #!/usr/bin/python

# vim: set fileencoding=<encoding name> : 例如,可添加# vim: set fileencoding=utf-8 :


python出现Non-ASCII character '\xe7' in file ex6.py on line 1, but no encoding declare错误

标签:python   python教程   python开发视频   python教学视频   python语言   

原文地址:http://blog.csdn.net/mjbaishiyun/article/details/45218811

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!