I have tried all the scripts mentioned in other questions, but not working for me.
for x in range (0,10):
print(x, end='\r', flush=True)
print(x, sep='\r', end='', flush=True)
print('\r', x)
Please help on this.
You probably want to overwrite the text, right?
You need to write backspaces to delete the last line and then print the next one. Check out this post for an example: How to create a spinning command line cursor?
>>> for x in range(10):
... print('\r', x, end='')
...
9>>>
As you can see, all the other numbers got overwritten because to the carriage-return symbol \\r
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.