Ich möchte die Python-Modul Progressbar verwenden.Python Progressbar Aktualisierung?
In meinem Fall möchte ich nach einem Wort in einer großen Liste suchen. Das funktioniert. Also dachte ich, eine Fortschrittsleiste wäre nett. Ich importierte das Modul und versucht es aus:
path = str(raw_input(PATH))
word = str(raw_input(WORD))
widgets = ['Suche Wort: ', pb.Percentage(), ' ',
pb.Bar(marker=pb.RotatingMarker()), ' ', pb.ETA()]
timer = pb.ProgressBar(widgets=widgets, maxval=10).start()
loc = -1
with open(path) as f:
for n in range(0,10):
timer.update(n)
for i, line in enumerate(f):
if word in line:
timer.update(n)
loc = i
break
timer.finish()
Aber es gibt ein Problem .. die progressbar bei 0% hält .Wenn die ganze Schleife beendet ist, es zu 100% springt. Warum?! Ich verstehe es nicht.
Vielen Dank im Voraus :)!