![](/img/trans.png)
[英]Python 2.7.8 (64bit) on Windows (64bit) is half as fast as 2.7.8 (64bit) on Ubuntu (64bit)
[英]Issue with downloading and executing a file: Python Windows 64bit
使用以下代碼在Windows 64中下載並執行文件時遇到奇怪的錯誤。 錯誤是我總是會拒絕訪問。 請注意,此代碼在Linux上運行良好,當我使用Window Explorer手動設置文件的完全權限時,我可以執行它(我不知道為什么,因為我的代碼已經設置了文件的完全權限)。
#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)
根據文檔 , os.chmod
只能在Windows系統上設置更改只讀權限。
看來問題是由我的人偶配置引起的,而不是python引起的,因為在父目錄中設置權限存在問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.