First, the difference between 1 double quotes and 3 double quotes, the string represented by double quotation marks is usually written as a line
Such as:
S1 = "Hello,world"
If you want to write multiple lines, then use \ ("line break"), such as
S2 = "hello,\
World
S2 and S1 are the same. If you use 3 double quotation marks, you can write directly, as follows:
S3 = "" "Hello,
World
hahaha. "", then S3 is actually "Hello,\nworld,\nhahaha.", note "\ n", so,
If you have a lot of strings in your string and you don't want to use \ n in a string, then you have 3 double
Quotes. Also, use 3 double quotation marks to add comments to the string, as follows:
S3 = "" "Hello, #hoho, this is hello, there can be comments in 3 double-quoted strings.
World, #hoho
hahaha. "" "
This is the difference between 3 double quotes and 1 double quotation marks, and the difference between 3 double quotes and 1 single quotes
Is the same as this, actually Python supports single quotes for a reason, let me compare 1 single quotes and
The difference between 1 double quotes.
When I use single quotation marks to represent a string, if I want to represent let's go this string, it must:
S4 = ' let\ ' go ', note that there is a ' in the string, and the string is used ' to denote, so
This is the time to use the escape character \ (\, escape character should know), if your string has a large heap of
The escape character, looks certainly uncomfortable, Python also solves this problem very well, as follows:
S5 = "Let ' s Go"
At this point, we see that Python knows that you are using "to represent strings, so Python will put that in the string
Single quotes ', as normal character processing, is not very simple.
The same is true for double quotes, and here's an example
S6 = ' I realy like ' python '! '
This is why both single and double quotation marks can represent strings.