84669 personnes étudient
152542 personnes étudient
20005 personnes étudient
5487 personnes étudient
7821 personnes étudient
359900 personnes étudient
3350 personnes étudient
180660 personnes étudient
48569 personnes étudient
18603 personnes étudient
40936 personnes étudient
1549 personnes étudient
1183 personnes étudient
32909 personnes étudient
假设有一个list是[2,1,4,1,5,1,6,1],如果我想统计这个list中有多少个1,以及每个1的位置,应该如何写呢?谢谢~~
认证高级PHP讲师
compte, indice de position
a = [1,2,3,1] a.count(1) # 2 a.index(1) # 0 [x for x in range(len(a)) if a[x] == 1] # 一次获得所有位置
compte, indice de position