Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8148629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:41:00+00:00 2026-06-06T14:41:00+00:00

The thing I want to know here should be really ‘basic’, but it is

  • 0

The thing I want to know here should be really ‘basic’, but it is a question in my mind for long time and no idea where the trick is.

Let’s say in a time-consuming program(either bash or Python), I have to print out the percentage of the progress when it’s running, and basically I want to print 1%, and after a certain time, I print 2%, etc.. I want '2%' to be displayed exactly at the same position where '1%' was displayed, rather than they’re like “1% 2%” or whatever. You know wget, what I want is exactly what wget does, to show the progress of the downloading progress. Do I need to clear the previously printed character, but how?

How does it work basically…

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:41:01+00:00Added an answer on June 6, 2026 at 2:41 pm

    I’m going to answer in Python, since it’s easier.

    You can print a backspace to the terminal to move the cursor to the left, and then write another character to overwrite the current position. You can also use a carriage return to go to the beginning of the line.

    import time
    import sys
    for x in range(101):
        sys.stdout.write('\r%d%%' % x)
        sys.stdout.flush()
        time.sleep(0.2)
    sys.stdout.write('\n')
    

    Using a carriage return and rewriting the whole line is the easiest, since you don’t have to be careful about how many backspaces to print.

    Note that if the new line is shorter than the old line, the old line will still show through.

    import sys
    sys.stdout.write('this is a very long line')
    sys.stdout.write('\rshort line')
    sys.stdout.write('\n')
    

    Output:

    short linevery long line
    

    A typical solution is to write spaces over the long line.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This one should be simple, but I don't really know how to find a
I want to know if we can select a thing on canvas through our
I want to know what does RETURN_VALUE mean! I'm stuck at this thing. How
First thing i want to say that it's not an easy question to explain,
I have some doubt on wget command. Here is the thing I want to
I'm stunned by a simple thing that I want to accomplish but does not
I have a question because I'm really bad at SQL. I understand basic functions
I just want to clarify one thing. This is not a question on which
There are some related questions here and here , but they didn't really give
I boiled the thing I want to do to the following minimal code: public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.