gpt4 book ai didi

ruby - 在Ruby中实现过程输出的最佳方法

转载 作者:行者123 更新时间:2023-12-03 06:19:51 24 4
gpt4 key购买 nike

gradle build中,我可以看到如下所示的当前过程:

# first is
> Loading
# and then change to
> Configuring > 0/1 projects > root project

我的问题是:如何在一行而不是两行中输出当前进程,例如:
# first is:
> 0/46 download tasks are finished
# and then change this line to
> 1/46 downaload tasks are finished

最佳答案

您可以使用回车键\r在同一行上重印,从而覆盖上一行:

10.times { |i| print "\r#{i}/10 times"; sleep 1 }
# => 5/10 times

关于ruby - 在Ruby中实现过程输出的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27123943/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com