li = [1, 2, 3, '456', [1, 2, 3], {1: 'one', 2: 'two'}]print(type(list))print(type(li))# 元素访问print(li[0])print(li[-1]) # li[len(li) - 1]print(li[-2]) # li[len(li) - 2]# 查找元素位置print(li.index('456'))print(li.index([1, 2, 3]))# print(li.index(-1))# 添加元素l_a = [1, 2, 3]l_a.append(4)l_a.append(5)l_b = [6, 7, 8]l_a.extend(l_b) # 试下用append是什么结果print(l_a)l_a = []if not l_a: print('Empty') # not XX和is None不是一回事if len(l_a) == 0: print('Empty')for i in li: print(i)for i in range(len(li)): print(li[i])t = (1, 2, 3, '456')print(type(t))#只读# t[0] = 'a'# t.append('x')del(li[-1]) # del(list[index])del(li[1])del(li[-2])print(li)
ca