- 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()
来源: http://www.phpxs.com/code/1005093/