久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <bdo id='3egh2'></bdo><ul id='3egh2'></ul>

      <tfoot id='3egh2'></tfoot>

      <small id='3egh2'></small><noframes id='3egh2'>

      <legend id='3egh2'><style id='3egh2'><dir id='3egh2'><q id='3egh2'></q></dir></style></legend>

    1. <i id='3egh2'><tr id='3egh2'><dt id='3egh2'><q id='3egh2'><span id='3egh2'><b id='3egh2'><form id='3egh2'><ins id='3egh2'></ins><ul id='3egh2'></ul><sub id='3egh2'></sub></form><legend id='3egh2'></legend><bdo id='3egh2'><pre id='3egh2'><center id='3egh2'></center></pre></bdo></b><th id='3egh2'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='3egh2'><tfoot id='3egh2'></tfoot><dl id='3egh2'><fieldset id='3egh2'></fieldset></dl></div>
    2. 多處理:使用 tqdm 顯示進度條

      Multiprocessing : use tqdm to display a progress bar(多處理:使用 tqdm 顯示進度條)
      <legend id='QOSr7'><style id='QOSr7'><dir id='QOSr7'><q id='QOSr7'></q></dir></style></legend>

        <small id='QOSr7'></small><noframes id='QOSr7'>

        • <tfoot id='QOSr7'></tfoot>

            <bdo id='QOSr7'></bdo><ul id='QOSr7'></ul>

          • <i id='QOSr7'><tr id='QOSr7'><dt id='QOSr7'><q id='QOSr7'><span id='QOSr7'><b id='QOSr7'><form id='QOSr7'><ins id='QOSr7'></ins><ul id='QOSr7'></ul><sub id='QOSr7'></sub></form><legend id='QOSr7'></legend><bdo id='QOSr7'><pre id='QOSr7'><center id='QOSr7'></center></pre></bdo></b><th id='QOSr7'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='QOSr7'><tfoot id='QOSr7'></tfoot><dl id='QOSr7'><fieldset id='QOSr7'></fieldset></dl></div>

                  <tbody id='QOSr7'></tbody>
              1. 本文介紹了多處理:使用 tqdm 顯示進度條的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                為了使我的代碼更pythonic"和更快,我使用多處理"和一個映射函數來發送它a)函數和b)迭代范圍.

                To make my code more "pythonic" and faster, I use "multiprocessing" and a map function to send it a) the function and b) the range of iterations.

                植入的解決方案(即直接在范圍 tqdm.tqdm(range(0, 30)) 上調用 tqdm)不適用于多處理(如下面的代碼所示).

                The implanted solution (i.e., call tqdm directly on the range tqdm.tqdm(range(0, 30)) does not work with multiprocessing (as formulated in the code below).

                進度條顯示從0到100%(python讀取代碼時?)但并不表示map函數的實際進度.

                The progress bar is displayed from 0 to 100% (when python reads the code?) but it does not indicate the actual progress of the map function.

                如何顯示進度條,指示地圖"功能在哪一步?

                from multiprocessing import Pool
                import tqdm
                import time
                
                def _foo(my_number):
                   square = my_number * my_number
                   time.sleep(1)
                   return square 
                
                if __name__ == '__main__':
                   p = Pool(2)
                   r = p.map(_foo, tqdm.tqdm(range(0, 30)))
                   p.close()
                   p.join()
                

                歡迎任何幫助或建議...

                Any help or suggestions are welcome...

                推薦答案

                找到的解決方案:小心!由于多處理,估計時間(每個循環的迭代次數、總時間等)可能不穩定,但進度條運行良好.

                Solution Found : Be careful! Due to multiprocessing, estimation time (iteration per loop, total time, etc.) could be unstable, but the progress bar works perfectly.

                注意:Pool 的上下文管理器僅適用于 Python 3.3 版

                Note: Context manager for Pool is only available from Python version 3.3

                from multiprocessing import Pool
                import time
                from tqdm import *
                
                def _foo(my_number):
                   square = my_number * my_number
                   time.sleep(1)
                   return square 
                
                if __name__ == '__main__':
                    with Pool(processes=2) as p:
                        max_ = 30
                        with tqdm(total=max_) as pbar:
                            for i, _ in enumerate(p.imap_unordered(_foo, range(0, max_))):
                                pbar.update()
                

                這篇關于多處理:使用 tqdm 顯示進度條的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                What exactly is Python multiprocessing Module#39;s .join() Method Doing?(Python 多處理模塊的 .join() 方法到底在做什么?)
                Passing multiple parameters to pool.map() function in Python(在 Python 中將多個參數傳遞給 pool.map() 函數)
                multiprocessing.pool.MaybeEncodingError: #39;TypeError(quot;cannot serialize #39;_io.BufferedReader#39; objectquot;,)#39;(multiprocessing.pool.MaybeEncodingError: TypeError(cannot serialize _io.BufferedReader object,)) - IT屋-程序員軟件開
                Python Multiprocess Pool. How to exit the script when one of the worker process determines no more work needs to be done?(Python 多進程池.當其中一個工作進程確定不再需要完成工作時,如何退出腳本?) - IT屋-程序員
                How do you pass a Queue reference to a function managed by pool.map_async()?(如何將隊列引用傳遞給 pool.map_async() 管理的函數?)
                yet another confusion with multiprocessing error, #39;module#39; object has no attribute #39;f#39;(與多處理錯誤的另一個混淆,“模塊對象沒有屬性“f)

                      <bdo id='NulfD'></bdo><ul id='NulfD'></ul>
                      <legend id='NulfD'><style id='NulfD'><dir id='NulfD'><q id='NulfD'></q></dir></style></legend>
                    • <small id='NulfD'></small><noframes id='NulfD'>

                    • <tfoot id='NulfD'></tfoot>
                        <tbody id='NulfD'></tbody>

                        <i id='NulfD'><tr id='NulfD'><dt id='NulfD'><q id='NulfD'><span id='NulfD'><b id='NulfD'><form id='NulfD'><ins id='NulfD'></ins><ul id='NulfD'></ul><sub id='NulfD'></sub></form><legend id='NulfD'></legend><bdo id='NulfD'><pre id='NulfD'><center id='NulfD'></center></pre></bdo></b><th id='NulfD'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='NulfD'><tfoot id='NulfD'></tfoot><dl id='NulfD'><fieldset id='NulfD'></fieldset></dl></div>

                          主站蜘蛛池模板: 欧美成人精品一区二区男人看 | 亚洲成人一区二区 | 中文字幕在线看人 | 欧美一级电影免费 | 久久激情视频 | 中文字幕亚洲区一区二 | 成人综合久久 | 一区二区三区高清 | 1区2区3区视频| 亚洲 欧美 综合 | 国产91在线 | 亚洲 | 欧洲成人免费视频 | 福利视频网站 | 久久久久久久久久久久久91 | 一区二区福利视频 | 国外成人在线视频网站 | 免费看a | 337p日韩| 日本免费一区二区三区 | 亚洲一区二区在线播放 | 一级片网址 | 中文字幕人成乱码在线观看 | 婷婷中文在线 | 日韩中出 | 午夜精品一区二区三区免费视频 | 欧美日韩一区二区在线播放 | 免费看a | 国产精品成人久久久久 | 精精国产xxxx视频在线播放 | 男女免费观看在线爽爽爽视频 | 极品一区 | 免费成人午夜 | 日韩中文字幕在线 | 红色av社区 | 精品成人av | 91极品尤物在线播放国产 | 天天操综合网站 | 欧美日韩久久精品 | 高清免费在线 | 毛片久久久 | 久久综合888|