\r and \n differences in Python

Solved
Hello,

In Python, what is the difference between \r and \n?
I'm referring here to two elements that are sometimes included in strings.

Thank you in advance

Configuration: Windows Vista / Internet Explorer 8.0

1 answer

  1. Contributor
    \r corresponds to the ASCII character CR.
    \n corresponds to the ASCII character LF.

    CR will allow you to return to the beginning of the line while LF will allow you to go to the next line.

    Best regards,
    --

    Google is your friend
    27
    1. Thank you very much, fiddy. What surprises me is that
      \n
      automatically goes to the next line, right?
      For example in
      input("your message \n")
      0
    2. Contributor
      Going to the next line or returning to the line is the same.
      0
    3. Thank you, fiddy. Yet sometimes we find
      \r\n
      Strange.
      0
    4. Contributor
      Yes. Because in fact this is more complicated than I explained to you.
      It depends on the OS.
      Specifically, to go to the next line under Windows, you need to use \r\n.
      Under GNU/Linux, you need to use \n, and under Mac OS, \r.
      0
    5. Perfect, thank you. My question is resolved.
      0