01三种删除方法
例子代码List
zllist = ['zhou','Python','IOS','zhou','xcode','pycharm','IPython']
01 remove
delete01 = zllist.remove('zhou')
print(zllist)02 del 删除 list
del zllist[1]
print(zllist)03 有返回值删除
delete03 = zllist.pop(1)
print(delete03)
print(zllist)
02 List切片 [1:2] 语法 拷贝 List 获得新的List 【起始位置(未设置从0开始):结束位置(未设置默认到尾部)】
print('[ : ]语法应用')
zllist = ['zhou','Python','IOS','zhou','xcode','pycharm','IPython']
a = zllist[1:2]
print(a)
b = zllist[1:]
print(b)
c = zllist[:1]
print(c)
[ : ]语法应用
['Python']
['Python', 'IOS', 'zhou', 'xcode', 'pycharm', 'IPython']
['zhou']
03 查找该类的所有方法
print(dir(zllist))
04 List 原序列 翻转 返回新序列
zllist02 = [1,2,3,4,5,9,80,7,68]
zllist02.reverse()
print(zllist02)
05sort 方法
正序
zllist02.sort()
print(zllist02)倒序
zllist02.sort(reverse=True)
print(zllist02)