我可以在python格式函数打印行中使用换行符吗?

我可以在python格式函数打印行中使用换行符吗?,python,printing,formatting,line-breaks,Python,Printing,Formatting,Line Breaks,这是我想分解的代码行,它工作得很好,但它是一条很长的代码行,如何在格式化函数中使用换行符来打印这样的行 return '{0.name} is a {0.sex} rabbit and has {0.fur_colour} fur and {0.eye_colour} eyes, {0.name} is of the {0.breed} breed of rabbits.\n{0.name} is '.format(paul)+ disp_age 您可以将整个拆分的字符串存储到() 关于多行字

这是我想分解的代码行,它工作得很好,但它是一条很长的代码行,如何在格式化函数中使用换行符来打印这样的行

return '{0.name} is a {0.sex} rabbit and has {0.fur_colour} fur and {0.eye_colour} eyes, {0.name} is of the {0.breed} breed of rabbits.\n{0.name} is '.format(paul)+ disp_age

您可以将整个拆分的字符串存储到
()

关于多行字符串的回答很有用:

这只是一个字符串,不是打印行函数。您可以通过在行末执行
\
来拆分总和。谢谢您的帮助。是的,这就是我一直在寻找的解决方案。谢谢。
return ("{0.name} is a {0.sex} rabbit"
    " and has {0.fur_colour} fur and "
    "{0.eye_colour} eyes, {0.name} is "
    "of the {0.breed} breed of rabbits.\n"
    "{0.name} is ").format(paul)+ disp_age