Python 3 tqdm Defects

Asked 2 years ago, Updated 2 years ago, 44 views

>>import tqdm
>>> from tqdm import tqdm
>>import time
>> for intqdm (range(100)):
    time.sleep(1)

Doing this

 0% | | 0/100 [00:00<?,?it/s]
  1% | 1 | 1/100 [00:01<01:40, 1.02s/it]
  2% | 2 | 2/100 [00:02<01:39, 1.01s/it]
  3% | 3 | 3/100 [00:03 <01:38, 1.01s/it]

(omitted)

 98% | #######8 | 98/100 [01:40<00:02, 1.02s/it]
 99% | ########9 | 99/100 [01:41<00:01,1.02s/it]
100% |#########|100/100 [01:42<00:00, 1.02s/it]

It appears for a total of 100 lines (actually without a new line).
Is this the correct behavior?

python

2022-09-30 21:15

1 Answers

The symptom of the question appears to be that the carriage return (\r) is not interpreted.

If you want to control the screen like tqdm, you need to use a terminal that can interpret the escape sequence.
idle and other repl types with IDE may not understand the escape sequence.
I think the questioner also works in that kind of environment.
It's okay if you use a normal device.

Even though it is operated by a normal device, if the phenomenon of the question occurs, as stated in argus's comment, the device may be strange.
If you can't reset it, it's better to restart it.

If from tqdm import tqdm, the previous import tqdm is not required.


2022-09-30 21:15

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.