tqdm.tqdm覆盖arg位置= gnome末端完成后的int = int

发布于 2025-02-03 19:43:32 字数 838 浏览 2 评论 0原文

编辑:由bash而不是tqdm

添加三个下载任务。指定。 完成任务后,无论分配了什么位置,它都会移至最高,并且底部的任务转移到了新线路,并在完成后的下一个终端输入中断。

    with tqdm(
        total=total,
        unit="B",
        unit_scale=True,
        unit_divisor=1024,
        leave=True,
        ncols=100,
        colour="green",
        position=index,
        dynamic_ncols=True,
        desc=f"{index}",
    ) as progress_bar, open(filelocation, "wb") as f:
        for chunk in r.iter_content(1024):
            progress_bar.update(len(chunk))
            if chunk:
                f.write(chunk)

PS:在图中,您可以看到任务2从其位置跳了两次。

Preview

EDIT : Caused by bash and not tqdm

Three download tasks are added with threading.Thread and the position for each of them is specified.
Upon completion of a task, it moves to the top irrespective of what position it was assigned, and the task at the bottom shifts to the new line and interrupts with the next input of the terminal upon completion.

    with tqdm(
        total=total,
        unit="B",
        unit_scale=True,
        unit_divisor=1024,
        leave=True,
        ncols=100,
        colour="green",
        position=index,
        dynamic_ncols=True,
        desc=f"{index}",
    ) as progress_bar, open(filelocation, "wb") as f:
        for chunk in r.iter_content(1024):
            progress_bar.update(len(chunk))
            if chunk:
                f.write(chunk)

PS: In the figure you can see task 2 has taken two jumps from its place.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文