gpt4 book ai didi

python - python 中的 "cannot execute binary file"错误

转载 作者:太空狗 更新时间:2023-10-30 00:11:47 27 4
gpt4 key购买 nike

我不断收到以下错误:

$ ./test.py
-bash: ./test.py: cannot execute binary file

当尝试通过 cygwin 在 python 中运行以下文件时:

#!usr/bin/python
with open("input.txt") as inf:
try:
while True:
latin = inf.next().strip()
gloss = inf.next().strip()
trans = inf.next().strip()
process(latin, gloss, trans)
inf.next() # skip blank line
except StopIteration:
# reached end of file
pass
from itertools import chain

def chunk(s):
"""Split a string on whitespace or hyphens"""
return chain(*(c.split("-") for c in s.split()))

def process(latin, gloss, trans):
chunks = zip(chunk(latin), chunk(gloss))

我该如何解决这个问题??


采纳了下面的建议后,还是报同样的错误。

如果这有帮助,我试过了

$ python ./test.py

得到了

$ python ./test.py
File "./test.py", line 1
SyntaxError: Non-ASCII character '\xff' in file ./test.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

最佳答案

有问题。您在 #!usr/bin/python 中缺少 usr 前面的“/”。您的行应如下所示。

#!/usr/bin/python

关于python - python 中的 "cannot execute binary file"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10460137/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com