Variable:
Variables in Python do not need to be declared beforehand, but need to be assigned before they are used, in the same way that other programming languages consist of letters, numbers, underscores, and the first cannot be numbers
String:
Python is enclosed in double or single quotation marks, but single and double quotes cannot be mixed, such as if the string itself contains a string, you can use the escape character
Let's go! two ways of writing:
1 ' let\ ' s go! ' 2 " Let ' s go! "
1 " Let ' s go! " 2 " Let ' s go! "
Original string:
When you want to use the backslash's own meaning, you can add a backslash to the front to escape character processing
1 Print ("c\\desktop") 2 C\desktop
However, for some special strings used frequently to backslashes, you can add a letter R in front of the string, you can easily solve
1>>>Print('C:\Program file\ntel\wifi\help')2 C:\Program File3 Tel\wifi\help4>>>Print('C:\\Program File\\ntel\\wifi\\help')#using escape character processing5 C:\Program file\ntel\wifi\help6>>>Print(r'C:\Program file\ntel\wifi\help')#using raw string processing7C:\Program File\ntel\wifi\help
Long string:
You can use single or double quotation marks to enclose only one line of string, if the string consists of multiple lines, you need to use three quotation marks
1>>>" "I love fish C,2 as I love the Little turtle. 3 The sound of his applause and applause,4 It always haunts my mind,5 Long refused to disperse. " "6 'I love fish c,\n as I love the Little turtle. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Applause, applause. '7>>>Print(" "I love fish C,8 as I love the Little turtle. 9 The sound of his applause and applause,Ten It always haunts my mind, One Long refused to disperse. " ") A I love fish C, - as I love the Little turtle. - The sound of his applause and applause, the It always haunts my mind, - Long refused to disperse.
"Py" variable, string, raw string, long string