卧槽!Python竟然能做这样的进度条。。。。。
菜鸟学Python
共 2894字,需浏览 6分钟
·
2021-01-18 10:56
公众号关注 “菜鸟学Python”
设为 “星标”,带你一起学编程!
机器之心编译
选自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 免责声明:本文内容来源于网络,文章版权归原作者所有,意在传播相关技术知识&行业趋势,供大家学习交流,若涉及作品版权问题,请联系删除或授权事宜。
程序员GitHub,现已正式上线! 接下来我们将会在该公众号上,专注为大家分享GitHub上有趣的开源库包括Python,Java,Go,前端开发等优质的学习资源和技术,分享一些程序员圈的新鲜趣事。
年度爆款文案
点这里,获取新手福利
评论