久久久久久久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>

                          主站蜘蛛池模板: 午夜免费小视频 | 亚洲成人av在线播放 | 国产1区2区 | 欧美日韩一区二区在线 | 中文字幕在线观看一区二区三区 | 久久久久久97 | 国产免费一区二区三区最新不卡 | 日韩大片在线观看 | 黄色av免费 | 久久久婷婷| 激情视频一区 | av毛片在线看 | 国产精品久久久一区二区 | 欧美性色网 | 日韩免费视频一区二区 | 黄色一级在线观看 | 99热最新| 免费三片在线播放 | 夜夜嗷| 天天爽天天操 | 伦理一区二区 | 亚洲性视频 | 久久国内精品 | 又色又爽又黄gif动态图 | 久久精品国产视频 | 中文精品一区 | 日本色综合 | 亚洲男人av | 日韩欧美高清 | 日韩欧美小视频 | 亚洲一区二区三区四区在线 | 国产传媒在线播放 | 国产91精品在线观看 | 亚洲一区二区在线视频 | 色综合久久久 | 在线一级片 | 免费黄色一级 | h视频在线播放 | 色婷婷视频在线观看 | 永久黄网站色视频免费观看w | 中文字幕一区二区三区在线观看 |