variable
The variables in Python are different from those in the C language. Python is a dynamically typed language, so there is no need to declare the type of the variable in advance. The type and value of the variable are initialized together at the moment of assignment. Each variable must be assigned a value before it is used, and the variable will not be created until the variable is assigned.
And the assignment statement in Python is to establish the reference value of the object, not the object, just like the pointer, not the area where the data is stored.
test_list=[1,2,3,4] new_list = test_list #Not a copy of test_list, just a reference to test_list new_list.append(5 ) print (test_list) # [1,2,3,4,5]
Therefore, the issues of deep copy and shallow copy will be involved, which will not be elaborated here, and will be discussed later.
basic data type
int (integer)
2. Boolean value (bool)
3. String
new_str="Hello,world"
String common functions:
- remove blank strip()
- split split()
- length len()
- index new_str[0]
- slice new_str[1:3]
name_list=[]
name_list=list([])
Basic operation:
- index
- slice
- Add append ()
- remove pop() remove()
- lengthlen()
new_tuple=(1,2,3)
Tuple contents are not modifiable
- index
- slice
- traverse
- length
- Include
new_dic={key1:value1,
Key2:value2}
Common operations:
- index
- new
- delete
- key, value, key-value pair
- traverse(key\value\key-value pair)
- length
operator
2. Comparison operation:
3. Assignment operation:
4. Logical operation:
5. Member operation:
operator
2. Comparison operation:
3. Assignment operation:
4. Logical operation:
5. Member operation: