Raw StringWith multiple lines of string
If a string contains many characters that need to be escaped, it can be cumbersome to escape each character. To avoid this, we can prefix the string with R, which means that it is a raw string, and that the characters inside it don't need to be escaped. For example:
R ' \ (~_~)/\ (~_~)/'
But R ' ... ' notation cannot represent multiple lines of string, nor can it represent a string containing ' and ' (Why?). )
If you want to represent multiple lines of string, you can use the"... "Said:
" ' line 1 '
Line 2
Line 3 "
The above string is represented in exactly the same way as the following:
' line 1\nline 2\nline 3 '
You can also add R in front of a multiline string and turn the multiline string into a raw string:
R ' ' Python is created by ' Guido '.
It's free and easy to learn.
Let's start learn Python in imooc! '
Python line break