Variable
When a value is assigned to a name, it is stored in memory
Firest = 3
Second = 8
Third = first + second
Print (third)
11
The use of variables requires attention:
1, before use, need to assign value to its first
2. Variable names can include letters, numbers, underscores, but cannot start with a number
3, the letter can make uppercase or lowercase, but the case is different
4, equal sign (=), the left is the name, the right is the value
String
The string is everything inside the quotation marks, the single double quotation mark does not stipulate
Cases:
5 + 8→13
' 5 ' + ' 8 ' →58.
What about single or double quotes in a string?
1. Escape symbol \ Escape the quotation marks in the string
Let ' s go→ ' let\ ' s go! ’
Raw string
Just put an English letter R in front of the string to
Cases:
str = ' C:\now '
Print (str)
C:
ow
str = R ' C:\now '
Print (str)
C:\now
Long string
Sanchong Quote String
Cases:
str = "" "Ah Ah ah Ah
No, no, no, no.
Ah, a quack. 1 ....
"""
Print (str)
Oh, ah, yes.
No, no, no, no.
Ah, a quack. 1 ...
Python variable definitions and strings