idle prints \r as ♪
Code
print('haha', end='\r')
print('haha\rhehe')
This is output
haha♪
haha♪hehe
#
Thanks for finding another same question! Is there any possible way to use \r? There is no explain about this...
idle prints \r as ♪
Code
print('haha', end='\r')
print('haha\rhehe')
This is output
haha♪
haha♪hehe
#
Thanks for finding another same question! Is there any possible way to use \r? There is no explain about this...
By default, python (not IDLE) sents print output to sys.stdout. IDLE connects sys.stdout to a tinter (tcl/tk) Text widget. What happens then depends on tk, the operating system, and the font you are using. For control characters other than tab ('\t') and enter ('\n'), the result is undefined. Possibilites include nothing, a space, and a puzzling symbol character. With 3.7.3 on Win 10 with SourceCodePro font, I see nothing. print('a\rb')
results in ab
. The IDLE doc, Help ==> IDLE Help, section User output in Shell discusses the printing of control characters.
To see what would happen if you run your code directly with python in a particular terminal or console, run it in that particular environment. To control output in detail regardless of OS, use a gui framework such as tkinter.