Strings can be represented by single quotation marks (' ... ') or double quotation marks ("..."), and \ can be used to escape quotation marks;
Case one: If there is no single quotation mark in the string and only double quotation marks, it is quoted in single quotation marks, otherwise it is quoted in double quotation marks.
For example, to print:
Doesn ' t: >>> "doesn ' t"
"Yes", he said >>> ' yes ', he said '
Alternatively, use the escape symbol \
Doesn ' t: >>> ' doesn\ ' t '
"Yes", he said >>> "\" yes\ ", he said"
Scenario Two: What happens if the character preceded by \ is treated as a special character? Add an R before the first quotation mark
>>>print ' C:\some\name ' c:\someame
In the example, \ n is considered a newline symbol, then the first quotation mark is preceded by R:
>>>print R ' C:\some\name ' C:\some\name
Scenario Three: The string wants to be divided into multiple lines, how to do?? Use "" "..." "" or ' ... '
Scenario four: How to concatenate multiple strings together??
(1) can use + (variable + string text also applies)
>>> ' app ' + ' le ' apple '
(2) Adjacent automatic connection (for two all string literals)
Scenario Five: How does a string be intercepted (retrieved)? Use subscript
Scenario Six: Want to change a character in a string, what to do??
WORD[1] = ' A ' This is not going to work!!!
Learn two python---strings