This article introduces you to the definition of a string in Python, a friend in need can refer to the content of the article
Defining strings in Python
> We've been explaining what a string is. Strings can be used " or "" is represented.
If the string itself contains ' What? For example we want to represent the string I ' m OK , at this point, you can use means:
"I ' m OK"
Similarly, if a string is contained " , we can use ' ' it as a means of enclosing:
' Learn ' Python "in Imooc '
What if the string contains ' and contains both " ?
this time, you need to " escape ", Python string with \ is escaped.
to represent the string bob said "I m OK".
because ' and ' can cause ambiguity, so we insert a \ Indicates that this is a normal character and does not represent the beginning of a string, so the string can be represented as a
' Bob said \ ' i\ ' m ok\ '. '
Note: the escape character \ does not count toward the contents of the string.
The usual escape characters are:
\ n indicates a newline \ t means a tab \ \ means \ character itself