简单来说,remove按值删除,pop按下标删除,clear为删除全部元素
pycharm测试
#测试remove,pop,clear的应用
L = ['a','b','c','d','e','f']
print(L)
#测试remove
L.remove('c')
print("remove之后结果:",L)
#测试pop
L.pop(2)
print("pop之后结果:",L)
#测试clear
L.clear()
print("clear之后结果:",L)
结果:
F:\python下载\python.exe F:/python下载/practical/qqqqqqqqqqqqqqqqqq/wen__.py
['a', 'b', 'c', 'd', 'e', 'f']
remove之后结果: ['a', 'b', 'd', 'e', 'f']
pop之后结果: ['a', 'b', 'e', 'f']
clear之后结果: []
Process finished with exit code