第壹個列表a需要按順序排列,使用itertools的groupby函數。
導入itertools
a=
print([[group,len(list(items))] for group,itertools.groupby(a)中的項目)
源代碼
第二個list A不需要順序很好,使用list的count函數。
print([[i,a . count(I)]for I in sorted(set(a))])