Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用字典生成器表达式(我为此使用 IDLE)在 python 中构建了非常大的字典(2^20 个元素)。这个过程很长,因为每个元素都需要硬计算。是否有可能获得此操作的已知进度?
我知道如果不使用生成器表达式很容易做到,但是我认为这个问题很有趣。
如果您使用编写生成器函数而不是仅使用生成器语句,则可以在每个语句yield之前放置日志记录或其他类型的反馈。yield
yield