加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – tqdm progressbar和colorama不能一起工作

发布时间:2020-12-20 13:16:53 所属栏目:Python 来源:网络整理
导读:我想使用colorama,但我已经在我的代码中使用了tqdm. 例: import colorama as colorimport tqdm as tqdm # without line it's workingprint(color.Fore.GREEN + 'Green text') 它在没有tqdm的情况下工作正常,但是如果我导入tqdm,在我重新启动控制台之前color
我想使用colorama,但我已经在我的代码中使用了tqdm.

例:

import colorama as color
import tqdm as tqdm  # without line it's working
print(color.Fore.GREEN + 'Green text')

它在没有tqdm的情况下工作正常,但是如果我导入tqdm,在我重新启动控制台之前colorama不对文本着色.我使用Spyder的IPython控制台(Python 3.6).

有没有办法可以将这些包装在一起使用?

解决方法

尝试如下( https://github.com/tqdm/tqdm/issues/450)

from tqdm import trange
from colorama import Fore
for i in trange(int(7e7),bar_format="{l_bar}%s{bar}%s{r_bar}" % (Fore.GREEN,Fore.RESET)):
    pass

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读