[issue43801] Carriage Return problem in version v3.9.0:9cf6752
Steven D'Aprano
report at bugs.python.org
Sat Apr 10 20:57:41 EDT 2021
Steven D'Aprano <steve+python at pearwood.info> added the comment:
Hello Santosh,
In future, please don't post images or screen shots of text, please copy and paste the text of your code.
You have something similar to this:
>>> text = "short line\rvery long line of text"
>>> print(text)
very long line of text
but you haven't told us what you expected to see instead or why you think it is a bug.
It isn't a bug, it is working correctly. Consider this version:
>>> text = "a very long line of text\rshort line"
>>> print(text)
short lineg line of text
Printing a carriage return returns the print location to the start of the line. To start a new line, you need a newline \n.
This is most commonly used for updating the display in place. Try running this code:
import time
def demo():
for i in range(1, 101):
print("\rUpdating record %d" % i, end='', flush=True)
time.sleep(0.1)
print()
----------
nosy: +steven.daprano
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43801>
_______________________________________
More information about the Python-bugs-list
mailing list