[Python] 纯文本查看 复制代码 ls = []
print(type(ls))
ls1 = ['a', 'b', 'c', 'd', 'e']
print(ls1[2])
print(ls1[-1])
ls2 = ['a', 'b', [1, 2, 3], 'd', 'e']
print(ls2[2][1])
ls3 = ['a', 'b', 'c', 'd', 'e']
print(ls3[1:3])
print(ls3[1:])
print(ls3[:3])
print(ls3[1::2])
print(len(ls3))
print(8 in ls3)
print(max(ls3))
print(ls3+ls2)
print(ls3*2)
ls4 = ['a', 'b', 'c', 'd', 'e']
del ls4[0]
print(ls4)
ls4.pop()
print(ls4)
ls4.pop()
print(ls4)
ls4.remove('c')
print(ls4)
ls4.clear()
print(ls4)
ls5 = ['a', 'b', 'c', 'd', 'e']
ls5.append(2)
print(ls5)
ls6 = ['a', 'b', 'c', 'c', 'd', 'e']
print(ls6.index('c'))
print(ls6.index('c'))
ls7 = ['z', 'b', 'f', 'd', 'c', 'd', 'e']
ls8 = sorted((ls7))
print(ls7)
print(ls8)
ls7.sort()
print(ls7)
|