Transferred from: http://www.cnblogs.com/known/archive/2010/07/31/1789290.html
1. Constants
Python constants have no Name
2. Number
There are 4 classes of Python:
* Integer: 2
* Long integers: 655535 and other large integers
* Floating point number: 1.2, 1.2e-3, E is a power of 10,
* Plural ( -5+4j)
3. String
Python does not have char type, single, double quote "", ' is a meaning
* Single quote: ' Quote me on this '
* Double quotes: "Waht's Your Name"
* Three quotes: ' This is the first line.
The second line.
Or
"What ' s your name?"
My name is known. "" "
* Escape character: ' what\ ' s your name? '
* Natural string: Start with R or R, r "Hello world!\n"
4. Variables
Name rule:
* The first character is a letter (uppercase or lowercase) or an underscore (_)
* Other part characters are letters (uppercase and lowercase), numbers, underscores
* Case-sensitive, myname and myname are two different variables
5. Data type
Python basically has no data type, which is the number and string, and the advanced type is the class
6. Objects
Python sees everything as an object, and it counts 2 as an object.
7. Logical lines and physical lines
The physical line is what you see in the editor. The logical line is what Python can recognize. In general, Python considers a physical line to correspond to a logical line.
If you want to use more than one logical line in a physical row, split it with a semicolon (;), which indicates the end of a logical line or statement. We recommend that you do not write this and that the readability is poor.
Example: i = 5;print (i)
Equivalent
i = 5
Print (i)
If you want to write a logical line in multiple physical rows, you use a backslash (\) to connect.
Example: s = "This is A\
String
Equivalent
s = "This is a string"
8 Indent
Indentation in Python is a test of importance. The gap at the beginning of the line is important, examples:
Print ("Hello")
Print ("World")
The second print statement will have an error because it has a blank space in front of it.
The statement of the consent level must have the same indentation.
Do not mix whitespace and tabs so that it will not work on different platforms.
It is strongly recommended that you use a single tab or two or four spaces when indenting. I suggest to use four spaces as always
9 operator
10 expressions
Python 1 Basic Concepts