How to print the progress of a list comprehension in python?

后端 未结 5 1373
忘掉有多难
忘掉有多难 2021-01-02 23:17

In my method i have to return a list within a list. I would like to have a list comprehension, because of the performance since the list takes about 5 minutes to create.

5条回答
  •  一生所求
    2021-01-02 23:49

    Here is my implementation.

    pip install progressbar2

    from progressbar import progressbar
    new_list = [your_function(list_item) for list_item in progressbar(old_list)]`
    

    You will see a progress bar while running the code block above.

提交回复
热议问题