找出数组中出现次数最多的数字
lt = [1, 1, 5, 2, 5, 2, 3, 7] count = {} for i in set(lt): count[i] = lt.count(i) print(count) max_value = max(count.values()) r = [] for k, v in count.items(): if v == max_value: r.append(k) print(r)
找出数组中出现次数最多的数字
lt = [1, 1, 5, 2, 5, 2, 3, 7] count = {} for i in set(lt): count[i] = lt.count(i) print(count) max_value = max(count.values()) r = [] for k, v in count.items(): if v == max_value: r.append(k) print(r)