所以我的問(wèn)題被否決了兩次,因?yàn)閾?jù)說(shuō)這個(gè)問(wèn)題是重復(fù)的:按頻率對(duì)計(jì)數(shù)器排序,然后在 Python 中按字母順序排序這里的答案是關(guān)于按字母順序排列 Counter Dictionnary 的。雖然我想按升序排序我想按頻率對(duì)字符串列表進(jìn)行排序。默認(rèn)情況下,我按降序獲取每個(gè)字符串的頻率。我做了一個(gè)letter_counts = Counter(list_of_string)). 我想我得到了一種按降序排列的字典。我想按升序?qū)λ鼈冞M(jìn)行排序,** 但到目前為止我還沒(méi)有管理它。我已閱讀如何按值對(duì)字典進(jìn)行排序?,但不能真正將其應(yīng)用于降序。frequency = Counter(list_of_string)print(frequency)我得到的字典(是嗎?)如下。如您所見(jiàn),它已經(jīng)按降序排列 Counter({' stan ': 3, ' type ': 3, ' quora ': 3, ' pescaparian': 3, ' python remove even number from a list': 3, ' gmail': 3, ' split words from a string ': 3, ' split python ': 2, ' split ': 2, ' difference entre list et set': 2, ' add a key to a dictionnary python': 1, ' stackoverflowsearch python add lists': 1})
添加回答
舉報(bào)
0/150
提交
取消