프로그램
[파이썬] cmd 창에서의 진척률(Progress) 표시
오디세이99
2022. 9. 26. 19:29
728x90
반응형
아래 그림과 같이 진척률을 보여 줍니다.
import sys
import time
def cmd_progress(end_val, view_length=20):
for i in range(0, end_val+1):
percent = float(i) / end_val
hashes = '#' * int(round(percent * view_length))
spaces = ' ' * (view_length - len(hashes))
sys.stdout.write("\rPercent: [{0}] {1}%".format(hashes + spaces, int(round(percent * 100))))
sys.stdout.flush()
time.sleep(0.1)
cmd_progress(100)
728x90
반응형