1、找出list中重复次数最多的元素
from collections import Counter
a_list = [1, 1, 7, 3, 6, 2, 5, 4, 4, 3, 9, 4, 4, 1]
#方法1
a = Counter(a_list).most_common(1)[0][0]
print(a)
#输出: 4
#方法2
b = max(a_list, key=a_list.count)
print(b)
#输出: 4
2、去除dict中首尾之外的内容
a_dict = {'a':1,'b':2,'c':3}
new_list = {}
new_list[list(a_dict.keys())[0]] = list(a_dict.values())[0]
new_list[list(a_dict.keys())[-1]] = list(a_dict.values())[-1]
print(new_list)