增(append)
list=['Alex','Leigou','Rock',1,2,3]
list.append('Sheer')
print(list)
运行结果:
D:\Anaconda3\python.exe...D:/PycharmProjects/pythonz/day2/z.py
['Alex', 'Leigou', 'Rock', 1, 2, 3, 'Sheer']
注:成功将字符串'Sheer'插入到列表中...', 1, 2, 3]
不包含下标位:
list=['Alex','Leigou','Rock',1,2,3]
list.pop()
print(list)
运行结果:
D:\Anaconda3\python.exe...具体实例如下:
list=['Alex','Leigou','Rock',1,2,3]
list.insert(2,'Sheer')
print(list)
运行结果:
D:\Anaconda3\python.exe...)可以统计列表中某个元素出现的次数,具体实例如下:
list=['l','h','l','g','f','l']
print(list.count("l"))
运行结果:
D:\Anaconda3\python.exe