[Python] python下载文件时显示下载进度的代码 →→→→→进入此内容的聊天室

来自 , 2019-12-23, 写在 Python, 查看 122 次.
URL http://www.code666.cn/view/c460dc0f
  1. def report(count, blockSize, totalSize):
  2.         percent = int(count*blockSize*100/totalSize)
  3.         sys.stdout.write("\r%d%%" % percent + ' complete')
  4.         sys.stdout.flush()
  5.  
  6. sys.stdout.write('\rFetching ' + name + '...\n')
  7. urllib.urlretrieve(getFile, saveFile, reporthook=report)
  8. sys.stdout.write("\rDownload complete, saved as %s" % (fileName) + '\n\n')
  9. sys.stdout.flush()
  10. #//python/8432

回复 "python下载文件时显示下载进度的代码"

这儿你可以回复上面这条便签

captcha