简体   繁体   English

语法错误:第 3 行文件 prueba.py 中的非 ASCII 字符“\\xe2”

[英]SyntaxError: Non-ASCII character '\xe2' in file prueba.py on line 3

I was trying something and I get this error.我正在尝试一些东西,但我收到了这个错误。 I searched and i found I have to add # encoding=utf8 but the output was different from what I was expecting我搜索并发现我必须添加 # encoding=utf8 但输出与我期望的不同

My code:我的代码:

print ' -------\n│      │\n│      │\n│     │\n││      │\n ------'

First error:第一个错误:

SyntaxError: Non-ASCII character '\xe2' in file prueba.py on line 3, but 
no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Code output:代码输出:

-------
Ôöé      Ôöé
Ôöé      Ôöé
Ôöé     Ôöé
ÔöéÔöé      Ôöé
------

I guess the problem is you define to use utf8 but don't use a utf8 string.我想问题是您定义使用 utf8 但不使用 utf8 字符串。 Maybe try to say print u' -------\\n│ │\\n│ │\\n│ │\\n││ │\\n ------'也许试着说print u' -------\\n│ │\\n│ │\\n│ │\\n││ │\\n ------'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM