【发布时间】:2014-03-08 05:45:30
【问题描述】:
我有一组 set 形式的字符串计数,我想将它除以一些 int 值。
例子:
Counter({'dlr': 21, 'said': 18, 'total': 17, 'bankamerica': 13, 'bank': 11, 'analyst': 9, 'prev': 9, 'februari': 8, 'york': 8, 'would': 8, 'price': 8, 'time': 8, 'wheat': 7})
我想将它除以某个 int 值,这样我将得到 count 除以该 int 值的单词。
我收到 TypeError: cannot concatenate 'str' 和 'int' 对象。
【问题讨论】:
-
这不是一套。这是一个
collections.counter,更像是一本字典。另外,请发布出现此错误的代码