不使用conu创建字典

2024-05-12 19:38:21 发布

您现在位置:Python中文网/ 问答频道 /正文

INFO是一个list,我正在使用Counter对它进行排序,并且希望输出是字典的形式。但是,我得到了一些不必要的字符:

wanted_dict = collections.Counter(INFO)
>>> Counter({'BLA': 102, 'BLABLA': 96, 'BLABLABLA': 96...})

不必要的字符是:

Counter
(
)

有没有办法输出以下内容

>>> {'BLA': 102, 'BLABLA': 96, 'BLABLABLA': 96...}

Tags: info字典排序counter字符collectionsdict形式