gpt4 book ai didi

python - time.sleep 有问题

转载 作者:行者123 更新时间:2023-11-28 20:29:13 25 4
gpt4 key购买 nike

例如,当我运行时:

print("[",end=" ")
time.sleep(1)
print("=",end=" ")
time.sleep(1)
print("=",end=" ")
time.sleep(1)
print("=",end=" ")
time.sleep(1)
print("=",end=" ")
time.sleep(1)
print("=",end=" ")
time.sleep(1)
print("=",end=" ")
time.sleep(1)
print("=",end=" ")
time.sleep(1)
print("=",end=" ")
time.sleep(1)
print("=",end=" ")
time.sleep(1)
print("=",end=" ")
time.sleep(1)
print("]",end=" ")

10 秒内没有任何反应,然后整个 [ = = = = = = = = = = ] 出现。我怎样才能防止这种情况发生,以便它可以充当一种进度条?

最佳答案

尝试在每次打印后刷新标准输出:

import sys

print("=",end=" ")
sys.stdout.flush()

关于python - time.sleep 有问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2814933/

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