当我尝试使用urllib.request.urlretrieve函数在python 3.3.2中下载文件时,出现以下错误:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python33\lib\tkinter\__init__.py", line 1475, in __call__
return self.func(*args)
File "C:\Python33\lib\site-packages\downloader.py", line 17, in startdownload
urllib.request.urlretrieve(url, file, reporthook)
File "C:\Python33\lib\urllib\request.py", line 191, in urlretrieve
tfp = open(filename, 'wb')
PermissionError: [Errno 13] Permission denied: '.\\tmp'
Run Code Online (Sandbox Code Playgroud)
我正在尝试将文件保存在桌面上的dir tmp中.我在模块"downloader.py"中使用以下代码:
def download(url, file):
import urllib.request, tkinter, os, time
from tkinter import ttk
def reporthook(blocknum, blocksize, totalsize):
readsofar = blocknum*blocksize
percent = readsofar * 1e2 / totalsize
GUI.title(str(int(percent)) + "% done")
PROGRESS["value"] = percent
PROGRESS.update() …Run Code Online (Sandbox Code Playgroud)