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:



More information about the Python-list mailing list