First, comparison operators:
list1> list2 compare the size of two lists, Python is compared directly from the 0-th element of the list, if equal, proceed to the next comparison
The result is a Boolean value
Second, logical operators
1 List1 = [123,234] 2 list2 = [123,345] 3 List1 < list2 4 True 5 6 List1 and list2 7 [123, 345] 8 list2 and List1 9 [123, 234]
Third, the operator splicing
Directly using the "+" connected to two lists, Note: "+" both sides must be a list
Fourth, the repetition operator
* A list of elements to repeat
1 list2 = [123,345] 2 list2*3 3 [123, 345, 123, 345, 123, 345]
Five members of the relational operators
in 和 not in
Note: The list element in the access list, the list must indicate the specific location of the element, see the following code
1 list2 = ['1232','23','柯珂',['adf',32]] 2 '23' in list2 3 True 4 32 in list2 5 False 6 32 in list2[3] 7 True
Sixth, the list of built-in method
clear()、copy()、count()、index()、reverse()、sort()
clear (): Empty list
copy (): the difference copy list, pay attention to the list assignment
count (parameter): count the number of the parameters appear in the list
reverse (): the list of all the elements upside down
index (value, start, stop): determines the start value to the end value of the
sort (key = None, reverse = True / Flase): When is False, then small to large, the descending order is True
Seven, list comprehensions
(A related expression for A in B)
1 list1 = [x**3 for x in range(5)] 2 lsit1 3 [0, 1, 8, 27, 64]