listx函数python_【Python】-列表LIST函数实例

#P3-107

L=[1,2,3,4,5];

L1=[7,8,9];

#append(x),添加X到L尾部

L.append(6)

print("L.append(6):",L);

#count(x),返回X在列表L中出现的次数

print("L.count(2):",L.count(2));

#index(x,start,end):返回L在列表中最左边现出现的索引

print("L.index(3):",L.index(3));

#extend(l),将L的项追加到列表结尾处

L.extend(L1)

print("L.extend(L1):",L);

#insert(x,i):在列表L索引i处插入X

L.insert(0,-1);

print("L.insert(0,-1):",L);

#reverse() 将列表L反向排序

L.reverse();

print("L.reverse:",L);

#sort():对列表L进行排序

L.sort();

print("L.reverse:",L);

#pop:返回并移除L最右边的数据项

L.pop();

print("L.pop:",L);

#pop(i):返回并移除列表L索引为i处的项

L.pop(2);

print("L.pop(2):",L);

s=L.pop(-1);

print("L.pop(-1):",L);

#赋值操作

first,*middle,end="Charles Philip Arthur George Windsor".split();

print("All is:Charles Philip Arthur George Windsor");

print("first:",first);

print("middle:",middle);

print("end:",end);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值