본문 바로가기
Python

[Py] 연습문제-carriage return + time.sleep

by ds31x 2025. 4. 7.

time.sleep 함수와 carriage return을 이용한 간단한 프로그래스바.

import time

l = ["-","/","|","\\"]

t = len(l)
def dp_progressbar():
    for i in range(100):
        idx = i%t
        prog = int(i//10)
        print(f"progressing... {l[idx]} : {'='*prog}{i:03d}%",end="\r")
        time.sleep(.1)
    print(f"progressing... - : {'='*10}100%")
    
dp_progressbar()

 

아주 간단한 progress bar!

 

https://youtu.be/MsuQxjFmis8