99问答网
所有问题
如何统计python list中元素的个数及其位置
如题所述
举报该问题
推荐答案 2016-12-16
l=[1,1,1,2,2,2,3,3,3,4]
total=len(l) #l总共的元素个数
e=1
howmany=l.count(e) #e在l中的个数
where=[i for i in range(len(l)) if l[i]==e] #e在l中的下标
温馨提示:答案为网友推荐,仅供参考
当前网址:
http://99.wendadaohang.com/zd/WezBBvBjjXBBeOevtjj.html
相似回答
大家正在搜
相关问题
如何统计python list中元素的个数及其位置
如何统计python list中元素的个数及其位置
如何统计python list中元素的个数及其位置
如何统计python list中元素的个数及其位置
如何统计python list中元素的个数及其位置
如何统计python list中元素的个数及其位置
如何统计python list中元素的个数及其位置
如何统计python list中元素的个数及其位置