why the output is different when i am implementig multiline string

Chris Angelico rosuav at gmail.com
Wed Jan 2 15:21:51 CET 2013


On Thu, Jan 3, 2013 at 1:00 AM,  <stringsatif1 at gmail.com> wrote:
>>>> '''hello
> world'''
> 'hello\nworld'
>>>> fred=''' hello
> world'''
>>>> print(fred)
>  hello
> world

That's because repr() converts the newline into "\n", while print
renders it literally. Check out repr() in the docs:

http://docs.python.org/3/library/functions.html?highlight=repr#repr

ChrisA



More information about the Python-list mailing list