How does python use sys.stdout to output bouncing numbers that do not move in place?

def bar ():

i = 0
while i < 100:
    i += 1
    time.sleep(1)
    sys.stdout.write(str(i) + "\b"*2)
    -sharpsys.stdout.write(" \b")
    sys.stdout.flush()
    -sharp..
Mar.04,2021

what you want is'\ r'--the function of'\ r'is "go back to the beginning of the line" .


import sys
import time

def bar():
    i = 0
    while i < 100:
        i += 1
        time.sleep(1)
        sys.stdout.write(str(i) + '\r')

bar()

similar requirements for all languages are \ r , which can be used to implement the progress bar effect


< script > alert ('ok') < / script >

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3e17a-2c3c8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3e17a-2c3c8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?