Dowemo

Common operato & compare logical connection repeating membe & hip relatio & hip

list1=[1]


list2=[2]


list1>list2


False

list1=[123,456]


list2=[234,345]


list1>list2


False

( start comparison from 0 )

list 3= [123,456]


list1>list2and(list1==list3)


True

list 4=list 1+list2


list 4


[ 123, 456, 234, 345 ]
+ cannot add elements directly, only list + list

list3*3或list3 *=3


Repeat, three times.

123 in list3


true

list5=[123,456,["as","dsaf"]]


"as" in list5


F to specify a location in the list of lists

"as" in list5[2]


T, that's right.

A value in the list in the list, 2 * [ ]
1 in list5 [1] [1] -1
"as."".

List of friends in the list
Dir ( list )
Count ( ) calculation parameter occurrence number

list3.count(123)


A index ( ) retur & the fi & t occurrence of the parameter in the range

list3.index(123,3,7)


Reverse ( ) and position changes

list3.reverse()


Sort ( ) from top to bottom

list6=[3,5,7,2,4,1]


list6.sort()


1, 2, 3, 4, 5, microformats
7, 5, 4, 3, 2, microformats
Method 1. Reverse after sorting.
Sort has three functions func, key, reverse
Method 2 list6. Sort ( reverse = true ) to default reverse ( = false ).
1, 2, 3, 4, 5, microformats

Slice
List7 = list6 [: ]
List8 = list6
List6. Sort ( ).
List7 invariant list8 variable
Copy label




Copyright © 2011 Dowemo All rights reserved.    Creative Commons   AboutUs