Pin-Jiun / Python

Python Document
0 stars 0 forks source link

33-progress bar #33

Open Pin-Jiun opened 1 year ago

Pin-Jiun commented 1 year ago
def show_progress_bar(count=0, total_count = 100, title:str = "", width=50):
    left =  int(count/total_count*width)
    right = width - left
    bar  = (u'\u25A0')*left
    spaces = " "*right
    percents = f"{count/total_count*100:.0f}%"
    print("\r[", bar, spaces, "]", percents, " ",title+"\r", sep="", end="", flush=True)    

for i in range(101):
    show_progress_bar(count = i,total_count = 100)
    sleep(0.05)
Pin-Jiun commented 1 year ago

https://stackoverflow.com/questions/3002085/how-to-print-out-status-bar-and-percentage https://www.codingem.com/progress-bar-in-python/ https://www.pythonpool.com/carriage-return-python/

from time import sleep
def progress(percent=0, width=40):
    left = width * percent // 100
    right = width - left

    tags = "=" * left
    spaces = " " * right
    percents = f"{percent:.0f}%"

    print("\r[", tags, spaces, "]", percents, sep="", end="", flush=True)
# Example run
for i in range(101):
    progress(i)
    sleep(0.05)
Pin-Jiun commented 1 year ago
import progressbar
from time import sleep
bar = progressbar.ProgressBar(maxval=20, \
    widgets=[progressbar.Bar('=', '[', ']'), ' ', progressbar.Percentage()])
bar.start()
for i in xrange(20):
    bar.update(i+1)
    sleep(0.1)
bar.finish()
Pin-Jiun commented 1 year ago

https://ithelp.ithome.com.tw/articles/10281072

Pin-Jiun commented 1 year ago

window系統,可以按win+r,在對話框里面輸入“charmap image

https://blog.csdn.net/Hello_Mr_Zheng/article/details/99352176