【发布时间】:2016-11-04 05:54:33
【问题描述】:
基本上我有列表(整个棕色语料库)。
dic1=brown.words()
print 'Total size of Brown Corpus :'
print len(dic1)
输出是:
Total size of Brown Corpus :
1161192
我将该列表转换为字典,使所有值都为 2 并检查了大小。
dic=dict((k,2) for k in dic1)
print 'Size of the dict:'
print len(dic)
得到了这个输出:
Size of the dict:
56057
字典包含:(key:2)。因此,如果列表中没有 1161192 个单词,则字典中也应该有相同数量的条目。为什么尺寸会发生变化?
【问题讨论】:
标签: python list dictionary