Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
下载和执行文件时出现问题:Python Windows 64位_Python_Windows_File_Permissions_32bit 64bit - Fatal编程技术网

下载和执行文件时出现问题:Python Windows 64位

下载和执行文件时出现问题:Python Windows 64位,python,windows,file,permissions,32bit-64bit,Python,Windows,File,Permissions,32bit 64bit,我在Windows64中下载并执行文件时遇到了一个奇怪的错误,代码如下。错误是我总是被拒绝访问。请注意,这段代码在Linux中运行良好,当我使用Windows资源管理器手动设置文件的完全权限时,我可以执行它(我不知道为什么,因为我的代码已经设置了文件的完全权限) 根据,os.chmod只能在Windows系统上设置更改只读权限。问题似乎是由我的puppet配置引起的,而不是python,因为在父目录中设置权限时存在问题 我的问题实际上是如何使文件可执行?文件是只读文件还是可执行文件并不重要。请注

我在Windows64中下载并执行文件时遇到了一个奇怪的错误,代码如下。错误是我总是被拒绝访问。请注意,这段代码在Linux中运行良好,当我使用Windows资源管理器手动设置文件的完全权限时,我可以执行它(我不知道为什么,因为我的代码已经设置了文件的完全权限)


根据,
os.chmod
只能在Windows系统上设置更改只读权限。

问题似乎是由我的puppet配置引起的,而不是python,因为在父目录中设置权限时存在问题

我的问题实际上是如何使文件可执行?文件是只读文件还是可执行文件并不重要。请注意,此问题仅在Windows 64位中发生。在Windows 32位中运行代码时没有问题。
#open url
u = urllib2.urlopen(download_url)

#create and write to a local file
with open(filename, 'wb') as f:
    block_sz = 8192
    while True:
        buffer = u.read(block_sz)
        if not buffer:
            break
        f.write(buffer)

#set full permission to the file
os.chmod(filename, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
os.system(filename)