python二进制文件打开出错_python中的“无法执行二进制文件”错误

我一直得到以下错误:$ ./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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值