1

I'm using the Python progress library to add a basic progress bar to my program, and I'm finding that it's printing extra unexpected characters. I've tried looking in the source code and the known issues, but I can't figure out what's happening.

Here's my code:

from progress.bar import Bar
import time

bar = Bar('Processing', max=10)

for i in range(10):
    time.sleep(1)
    bar.next()

bar.finish()

Per the documentation, I should expect a bar like the following:

Processing |#############                   | 5/10

But the actual output looks like this:

[KProcessing |################################| 10/10
[?25h

Here it is as a picture so you can see the weird characters

Why is it printing the "K" and "[?25h" and the weird question mark in the box?

Where is the "K" and the weird question mark and the "[?25h "? How do I get rid of these?

leorar
  • 43
  • 3

1 Answers1

1

These are VT100 or ANSI escape codes as described in this SO answer.

Essentially, your terminal/shell is not recognizing the control codes being used by the library. Try a unicode compatible shell and you'll likely get the expected result.

kerasbaz
  • 1,774
  • 1
  • 6
  • 15