切片操作(同字符串)(略)

列表的遍历

for obj in listObj

print(obj)

 1 >>> a = [10,20,30,40,50,60,70]
 2 >>> a
 3 [10, 20, 30, 40, 50, 60, 70]
 4 >>> for x in a:
 5     print(a)
 6 
 7     
 8 [10, 20, 30, 40, 50, 60, 70]
 9 [10, 20, 30, 40, 50, 60, 70]
10 [10, 20, 30, 40, 50, 60, 70]
11 [10, 20, 30, 40, 50, 60, 70]
12 [10, 20, 30, 40, 50, 60, 70]
13 [10, 20, 30, 40, 50, 60, 70]
14 [10, 20, 30, 40, 50, 60, 70]
15 >>> print(x)
16 70
17 >>> a = [10,20,30,40,50,60,70]
18 >>> a
19 [10, 20, 30, 40, 50, 60, 70]
20 >>> for x in a:
21     print(x)
22 
23     
24 10
25 20
26 30
27 40
28 50
29 60
30 70
 1 >>> a = [10,30,50,70,90,70,40,20,90,70]
 2 >>> a
 3 [10, 30, 50, 70, 90, 70, 40, 20, 90, 70]
 4 >>> a[:]
 5 [10, 30, 50, 70, 90, 70, 40, 20, 90, 70]
 6 >>> a[3:2]
 7 []
 8 >>> a[3:5]
 9 [70, 90]
10 >>> a[::2]
11 [10, 50, 90, 40, 90]