Typing \n in strings

Paul Watson pwatson at redlinepy.com
Sat Apr 3 21:58:14 EST 2004


"Edward Diener" <eldiener at earthlink.net> wrote in message
news:RGKbc.11130$yN6.10939 at newsread2.news.atl.earthlink.net...
> Python 2.3.3 on Win2K. In the Python tutorial it says that typing \n in
> string literals is the new-line character. I open the interpreter and type
a
> string with a \n in it but instead of outputting a string with a new line,
> it outputs the \n as literal characters of the string. Is the tutorial
> wrong, is the interpreter broken, or what is happening ?
>

What exactly are you entering and what is output?

Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> "now\nis\nthe\ntime"
'now\nis\nthe\ntime'
>>> print "now\nis\nthe\ntime"
now
is
the
time
>>> s = 'now\nis\nthe\ntime'
>>> s
'now\nis\nthe\ntime'
>>> print s
now
is
the
time





More information about the Python-list mailing list