Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
\\n in code
#2
\ has a special meaning in Python. So you have to escape it if you want to print it.

Printing single \ is not going to work that way because you are escaping the close quote
>>> print("\")
  File "<stdin>", line 1
    print("\")
             ^
SyntaxError: EOL while scanning string literal
As it is here.
>>> print("\"")
"
To print \ you have to escape it with another \
>>> print("\\")
\
Here you cannot escape 's' because '\s' do not have special mieaning.
>>> print("\s")
\s
But '\n' represents a new line character.
>>> print("\n")
So to print \n you have to escape the \
>>> print("\\n")
\n
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Messages In This Thread
\\n in code - by Dixon - Feb-20-2018, 11:48 PM
RE: \\n in code - by wavic - Feb-20-2018, 11:58 PM
RE: \\n in code - by abhin - Feb-21-2018, 02:59 AM
RE: \\n in code - by nilamo - Mar-22-2018, 07:19 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020