In a Python script I’m looking at the string has a \ before it:
print """\ Content-Type: text/html\n <html><body> <p>The submited name was "%s"</p> </body></html> """ % name
If I remove the \ it breaks. What does it do?
It tells Python to ignore the newline directly following the backslash. The resulting string starts with
Content-Type:, not with
>>> '''\ This is the first line. This is the second line. ''' 'This is the first line.\nThis is the second line.\n' >>> ''' ... This is the first line. ... This is the second line. ... ''' '\nThis is the first line.\nThis is the second line.\n'
Note how the two results differ; the first has no
\n newline character at the start, the other does.