python下载文件时显示下载进度的代码,,def report(c
python下载文件时显示下载进度的代码,,def report(c
def report(count, blockSize, totalSize): percent = int(count*blockSize*100/totalSize) sys.stdout.write("\r%d%%" % percent + ' complete') sys.stdout.flush()sys.stdout.write('\rFetching ' + name + '...\n')urllib.urlretrieve(getFile, saveFile, reporthook=report)sys.stdout.write("\rDownload complete, saved as %s" % (fileName) + '\n\n')sys.stdout.flush()
评论关闭