0
How \r works, any one give me an example?
5 Antworten
+ 2
Carriage return or \r is a very unique feature of Python. \r will just work as you have shifted your cursor to the beginning of the string.
Whenever you will use this special escape character \r, the rest of the content after the \r will come at the front of your line and will keep replacing your characters one by one until it takes all the contents left after the \r in that string.
Ex:
print('hello world\r123')
Output:123lo world
print('hello world\r1234299')
Output: 1234299orld
(Even space is a character)
+ 2
Thanks Khentit Nadji Sabri It's nice to learn learn something new!
+ 1
But I got the output as hello world123
+ 1
Carriage return is not working in my app
0
Nazma Sheik
Yea in some gui editors like here in sololearn but u can run it on console.
Use :
from __future__ import print_function
In ur code to run it properly.