亚洲免费乱码视频,日韩 欧美 国产 动漫 一区,97在线观看免费视频播国产,中文字幕亚洲图片

      1. <legend id="ppnor"></legend>

      2. 
        
        <sup id="ppnor"><input id="ppnor"></input></sup>
        <s id="ppnor"></s>

        python下載文件時顯示下載進度的方法

        字號:


            具體分析如下:
            將這段代碼放入你的腳本中,類似:urllib.urlretrieve(getFile, saveFile, reporthook=report)
            第三個參數(shù)如下面的函數(shù)定義report,urlretrieve下載文件時會實時回調report函數(shù),顯示下載進度
            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()