python - 如何获取tqdm的当前值?

标签 python tqdm

如何获得更新的 tqdm.n? 此代码似乎有效:

from tqdm import tqdm
pbar = tqdm(range(10000))
for i in pbar:
     pbar.refresh()
     print 'pbar', pbar.n

我必须调用 tqdm.refresh() 吗?

最佳答案

这似乎可行

from tqdm import tqdm
class TqdmSpy(tqdm):
    @property
    def n(self):
        return self.__n

    @n.setter
    def n(self, value):
        print(value, self.total)
        self.__n = value

关于python - 如何获取tqdm的当前值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55458145/

相关文章:

python - 在 Python 中对数组进行切片时单步执行多个值

python - 将文本添加到矩形上

python - 在 PyYAML 中格式化自定义类输出

python - 如何为从大型 xlsx 文件加载 pandas DataFrame 创建进度条?

python - 在 Python 中将可变长度字符串拆分为变量的最佳方法是什么?

python - 剥离 xpath 中的附加项

python - tqdm的total参数有什么作用?

python - 是否可以使用 tqdm 进行 pandas 合并操作?

python - charm.pool.map 和 tq​​dm : obtain a progressbar

python - tqdm:提取已过去的时间+剩余时间?