>>> for i in range(1,10,2):
print(i) ##打印奇数
1
3
5
7
9
列表也可以用相同的方法 (切片)
>>> a
[‘ergou‘, ‘hanmeimei‘, [‘aaa‘, ‘qqqq‘], ‘jiajia‘, ‘jiajia‘, ‘jiajia‘, 1, 2, 3, 4, 5, ‘qqqq‘]
>>> for i in a[0:-1:2]:
print(i)
ergou
[‘aaa‘, ‘qqqq‘]
jiajia
1
3
5
>>>