列表的用法:'''列表是有序、可嵌套,元素可重複出現'''names = ['grape','bajie','haha','chenglong','wukong',['1','2','3']]print(names[names.index('grape')]print(names[0])print(names[0:2])print(names[:2])print(names[-2:-1])print(names[-2])names.append('bajie')print(names)names.insert(1,'honghaier')print(names)names[2]='tangseng'print(names)names.remove('lili')print(names)names.pop(2)print(names)print(names.count('wukong'))print(names.reverse())print(names)names2=['1','2','3']names.extend(names2)print(names)names.sort()print(names)print(names)names3=names.copy()#淺拷貝,只對第一層拷貝。names[-1][2]=4names[0]='Grape'print(names)print(names3)