卧槽!Python竟然能做这样的进度条。。。。。
恋习Python
共 2507字,需浏览 6分钟
·
2021-01-19 12:32
机器之心编译
选自towardsdatascience 作者:Costas Andreou
import timefrom progress.bar
import IncrementalBarmylist = [1,2,3,4,5,6,7,8]
bar = IncrementalBar( Countdown , max = len(mylist))
for item in mylist:
bar.next()
time.sleep(1)
bar.finish()
Progressbar 的增量进度条
ProgressBar 支持的进度条类型。
import timefrom tqdm
import tqdmmylist = [1,2,3,4,5,6,7,8]
for i in tqdm(mylist):
time.sleep(1)
from alive_progress import alive_barimport
timemylist = [1,2,3,4,5,6,7,8]
with alive_bar(len(mylist)) as bar:
for i in mylist:
bar()
time.sleep(1)
import PySimpleGUI as sgimport
timemylist = [1,2,3,4,5,6,7,8]
for i, item in enumerate(mylist):
sg.one_line_progress_meter( This is my progress meter! , i+1, len(mylist), -key- )
time.sleep(1)
import PySimpleGUI as sgimport
timemylist = [1,2,3,4,5,6,7,8]
progressbar = [ [sg.ProgressBar(len(mylist), orientation= h , size=(51, 10), key= progressbar )]]
outputwin = [ [sg.Output(size=(78,20))]]
layout = [ [sg.Frame( Progress ,layout= progressbar)], [sg.Frame( Output , layout = outputwin)], [sg.Submit( Start ),sg.Cancel()]]
window = sg.Window( Custom Progress Meter , layout)
progress_bar = window[ progressbar ] while True:
event, values = window.read(timeout=10)
if event == Cancel or event is None:
break
elif event == Start :
for i,item in enumerate(mylist):
print(item)
time.sleep(1)
progress_bar.UpdateBar(i + 1)window.close()
参考链接:https://towardsdatascience.com/learning-to-use-progress-bars-in-python-2dc436de81e5 免责声明:本文内容来源于网络,文章版权归原作者所有,意在传播相关技术知识&行业趋势,供大家学习交流,若涉及作品版权问题,请联系删除或授权事宜。
恋习Python 关注恋习Python,Python都好练 好文章,我在看❤️
评论