Next: Triple-quoted strings Up: String Literals Previous: Double Quotes

Continuation Of String Literals

String literals can span multiple lines by escaping newlines with backslashes, e.g.


        hello = "This is a rather long string containing\n\
        several lines of text just as you would do in C.\n\
            Note that whitespace at the beginning of the line is\
         significant.\n"
        print hello

which would print the following:


        This is a rather long string containing
        several lines of text just as you would do in C.
            Note that whitespace at the beginning of the line is significant.


guido@cwi.nl