Skip to content

Commit

Permalink
feat(libs): add progress_bar
Browse files Browse the repository at this point in the history
  • Loading branch information
WokoLiu committed Aug 19, 2019
1 parent c821f30 commit cb94f10
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions libs/progress_bar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# @Time : 2019-07-25 22:39
# @Author : Woko
# @File : progress_bar.py

"""进度条"""

import time


def progress_bar(num, total):
rate = float(num) / total
ratenum = int(100 * rate)

r = f'\r[{"*" * ratenum}{" " * (100 - ratenum)}]{ratenum}%'
print(r, end='\r')


for i in range(100):
time.sleep(0.1)
progress_bar(i + 1, 100)

0 comments on commit cb94f10

Please sign in to comment.