What does it mean?

What does "\ r" mean? What does it do? I had never seen this before, and it gave me headaches. This does not seem to have any purpose, since "a \ ra" prints as "aa", but this is not the same as the string "aa". Im using python 2.6

+3
source share
4 answers

This is an old control character from typewriters. This means "carriage return." At this time, when you pressed enter, you went to the next line, then the carriage returned to the beginning of the line (hence, carriage return). Then with computers, different operating systems made different options for presenting new lines. In windows you have "\ r \ n" (carriage return + new line). In Unices you only have "\ n" (there is no need to do a carriage return, this was due to a new line). On old Mac OS, you only had "\ r".

Currently, it is not used, except for newlines (or I do not know other ways to use it).

+10
source

For me (on Mac OS X 10.5 Terminal.App, Python 2.6.5):

>>> print 'a\ra'
a

or give a better example:

>>> print 'longstring\rshort'
shorttring

IOW, \r " " ( ), 'short' "" 'longstring'.

" ", - print '\rupdate', , , . , , , , , ( ).

, ( , \r , ), ! -)

+8

. , Windows, print 'a\ra' ...

a
a

... .

.

  • \newline -
  • \\ - ()
  • \' - (')
  • \" - (")
  • \a - ASCII Bell (BEL)
  • \b - ASCII Backspace (BS)
  • \f - ASCII Formfeed (FF)
  • \n - ASCII Linefeed (LF)
  • \N{name} - ( )
  • \r - ASCII (CR)
  • \t - ASCII (TAB)
  • \uxxxx - 16- xxxx ( Unicode)
  • \Uxxxxxxxx - A character with a 32-bit hexadecimal value xxxxxxxx (Unicode only)
  • \v - Vertical Tab ASCII (VT)
  • \ooo - character with octal value ooo
  • \xhh - character with hexadecimal value hh
+1
source

there should be a carriage return ... something like a new line ... look at http://www.wilsonmar.com/1eschars.htm

0
source

Source: https://habr.com/ru/post/1756436/


All Articles