python - Add a key with colon to a Counter -
i want add key counter object has several colon (:) characters inside. problem counter object adds key every character in key. example:
>>> cc = counter() >>> cc.update("1:2:3") >>> cc counter({':':2, '1':1, '2':1, '3':1}) i want counter counter({'1:2:3':1}). how can that?
insert dictionary counter update, this:
from collections import counter cc = counter() cc.update({"1:2:3":1}) print cc 'counter({'1:2:3': 1})'
Comments
Post a Comment