在Python中解压缩EXE文件会出现与windows不兼容的错误

在Python中解压缩EXE文件会出现与windows不兼容的错误,python,windows,zipfile,Python,Windows,Zipfile,我正在写一个程序,需要从一个设定的位置下载其他程序。在Mac OS X上测试时,我可以毫无问题地下载和运行这些程序,但在Windows上下载和解压缩文件时,会出现以下错误: The version of this file is not compatible with the version of Windows you are running. 然后描述了我如何检查是否需要x86或x64版本。我已经使用Winrar解压了同一个文件,并且包含的程序运行顺利,所以我相当确定这是我的代码 def

我正在写一个程序,需要从一个设定的位置下载其他程序。在Mac OS X上测试时,我可以毫无问题地下载和运行这些程序,但在Windows上下载和解压缩文件时,会出现以下错误:

The version of this file is not compatible with the version of Windows you are running.
然后描述了我如何检查是否需要x86或x64版本。我已经使用Winrar解压了同一个文件,并且包含的程序运行顺利,所以我相当确定这是我的代码

def _unzip_(self,file,destdir):
    print "Unzipping %s to %s" % (file,destdir)
    z = zipfile.ZipFile(file)
    for f in z.namelist():
        # Zipfiles store paths internally using a forward slash. If os.sep
        # is not a forward slash, then we will compute an incorrect path.
        # Fix that by replacing all forward slashes with backslashes if
        # os.sep is a backslash
        if os.sep == "\\" and "/" in f:
            destfile = os.path.join(destdir,f.replace("/","\\"))
        else:
            destfile = os.path.join(destdir,f)
        if destfile.endswith(os.sep):
            if not os.path.exists(destfile):
                os.makedirs(destfile)
        else:
            file = open(destfile,"w")
            file.write(z.read(f))
            file.close()
    z.close()
如果您能提供任何帮助,我们将不胜感激。

请使用

open(destfile,"wb")
以二进制模式写入文件。

使用

open(destfile,"wb")

以二进制模式写入文件。

工作正常。非常感谢。工作得很好。非常感谢。