Kud*_*udu 2 python buffering python-3.x
当我跑步时,例如:
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=" ")
Run Code Online (Sandbox Code Playgroud)
10秒钟没有任何事情发生,然后整个[= = = = = = = = =]出现.我怎样才能阻止它,以便它可以作为一种进度条呢?
每次打印后尝试刷新标准输出:
import sys
print("=",end=" ")
sys.stdout.flush()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
595 次 |
| 最近记录: |