python中"无法执行二进制文件"错误

use*_*310 6 python cygwin

我一直收到以下错误:

$ ./test.py
-bash: ./test.py: cannot execute binary file
Run Code Online (Sandbox Code Playgroud)

当试图通过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))
Run Code Online (Sandbox Code Playgroud)

我该如何解决??


在采取以下建议后,仍然得到相同的错误.

如果这有帮助,我试过了

$ python ./test.py
Run Code Online (Sandbox Code Playgroud)

得到了

$ 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
Run Code Online (Sandbox Code Playgroud)

kof*_*ann 4

有一个问题。您缺少 usr 前面的“/” #!usr/bin/python。你的线路应该是这样的。

#!/usr/bin/python