我有这个代码:
import collections
def last3scores():
return collections.deque([], 3)
user_last3 = collections.defaultdict(last3scores)
#after this I have some more code and then this:
user_last3[name].append(score)
print(str(user_last3))
但当我运行程序时,我得到的是:
^{pr2}$我想要的是:
{'nick': [2]}
在Python3.*中有没有实现这一点的方法?在
也许你可以试试以下几点:
这应该能做到这一点(在python3中,*切换到}):
items
而不是{相关问题 更多 >
编程相关推荐