#! /usr/bin/env python3
# _*_ coding: UTF-8 _*_

import sys
import time

print("downloading：")


def view_bar(num, total):
    rate = float(num) / float(total)
    rate_num = int(rate * 100)
    r = "\r"+("="*(2*rate_num//10)+">") + \
        (" "*(20-2*rate_num//10))+'%d%%' % (rate_num, )
    sys.stdout.write(r)
    sys.stdout.flush()  # 刷新缓冲区


if __name__ == '__main__':
    for i in range(0, 101):
        time.sleep(0.01)
        view_bar(i, 100)


print("\ndownload successful\n")
