#!/usr/bin/env python # -*- coding:utf-8 -*- a = [1, 2, 3, 4, 5] # 索引 print(a[0], a[1], a[2], a[3], a[4]) print('-'*20) # 切片 print(a[:]) print(a[:3]) print(a[0], a[1], a[2], a[3], a[4]) print(a[-1], a[-2], a[-3], a[-4], a[-5]) print('-'*20) # append a.append(6) print("append",a) # remove a.remove(6) print("remove",a) # del del a[-1] print("del",a) # pop a.pop() print("pop",a) # extend a.extend([4,5,6]) print("extend",a) # copy c = a.copy() print("copy",c) # reverse a.reverse() print("reverse:",a) # sort a.sort() print("sort:",a) # count print("count:",a.count(2)) # index print("index:",a.index(5))