Ask how to show file download buffering

Asked 2 years ago, Updated 2 years ago, 74 views

We are creating a simple console application that uploads/downloads files to an FTP server via ftplib.

When uploading/downloading data, I want to show you how much buffering has progressed, but if you print it out one line at a time,

*
**
***

(When * is in progress) The previous buffering record remains like this. <

buffering python console

2022-09-21 17:20

1 Answers

\r moves the cursor to the beginning of the line.

#Code increments by 1% every 1 second

import time
import sys

for i in range(100):
    time.sleep(1)
    sys.stdout.write("\r%d%%" % i)
    sys.stdout.flush()


2022-09-21 17:20

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.