Ascii文件中的Python BOM错误 [英] Python BOM error in Ascii file
问题描述
http://svn.tuxisalive。 com / software_suite_v3 / smart-core / smart-server / trunk / TDSService.py
我收到这个错误:
文件tuxhttpserver.py,第1行
SyntaxError:编码问题:
BOM
我知道错误是关于BOM字节等。但是,没有BOM字节,这是简单的Ascii。我检查一个Hexeditor,并且linux文件命令表示它的Ascii。
我在这里吓倒了...代码在我的Sheevaplug(也是一个基于ARM的系统)
不要太挂在使用BOM的评论。这可能是不相关的这个错误通常意味着您尝试运行的Python不支持您声明的编码。观察:
%head -1 tmp.py
# - * - 编码:asdfasdfasdf - * -
%python tmp.py
文件tmp.py,第1行
语法错误:编码问题:使用BOM
您在此嵌入式Linux ARM板上运行的Python安装可能缺少latin-1编码。由于您的源文件中没有任何非ASCII字符,只需将编码声明为ascii即可,完全不用编码。
I have a weird, annoying problem with Python 2.6. I'm trying to run this file (and the other), on my Embedded Linux ARM board. http://svn.tuxisalive.com/software_suite_v3/smart-core/smart-server/trunk/TDSService.py
I get this error:
File "tuxhttpserver.py", line 1 SyntaxError: encoding problem: with BOM
I know that error is about the BOM bytes etc etc. BUT, there are NO BOM bytes, it's plain Ascii. I checked with a Hexeditor, and the linux File command says its Ascii.
Im freaking out here... The code worked fine on my Sheevaplug (also a ARM based system).
Don't get too hung up on the "with BOM" remark. It's probably not relevant. What this error usually means is that the Python you are trying to run in does not support the encoding you declare. Observe:
% head -1 tmp.py
# -*- coding: asdfasdfasdf -*-
% python tmp.py
File "tmp.py", line 1
SyntaxError: encoding problem: with BOM
The Python installation you are running on this Embedded Linux ARM board probably lacks the 'latin-1' encoding. Since you don't have any non-ASCII characters in your source file, just declare the encoding as 'ascii', or leave out the encoding altogether.
这篇关于Ascii文件中的Python BOM错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!