numlist=[1,2,3,4,5,6,7,8,9]
numlist[::-1]
#######运行结果######
[9, 8, 7, 6, 5, 4, 3, 2, 1]
numlist=[1,2,3,4,5,6,7,8,9]
numlist[::2]
#######运行结果######
[1, 3, 5, 7, 9]
7.列表–list-常用操作符
list1=[123,456]
list2=[456,789]
list1>list2
#######运行结果######
False
list3=['abc']
list4=['bcd']
list3>list4
#######运行结果######
False
list.count():统计出现的次数
numlist = [1,1,2,3,4,[1,2,3,5],5,6,9,8,7]
numlist.count(5)
#######运行结果######
1
list.index():返回第一个遇见的位置
dir(list)
numlist = [1,1,2,3,4,[1,2,3,5],5,6,9,8,7]
numlist.index(1)
#######运行结果######
0
list.clear():清表
numlist = [1,1,2,3,4,4,5,6,9,8,7]
numlist.clear()
print(numlist)
#######运行结果######
[]