我有这样一个数据结构:
poll = {
'LINK' : {'MoonRaccoon' : 1, 'TheDirtyTree' : 1},
'ZRX' : {'MoonRaccoon' : 1, 'Dontcallmeskaface' : 1, 'TheDirtyTree' : 1},
'XRP' : {'Dontcallmeskaface' : 1},
'XLM' : {'aeon' : 1, 'Bob' : 1}
}
我希望它最终能像这样打印,按每个请求者的数量排序,然后按字母顺序打印股票代码,然后按字母顺序打印用户
!pollresults
ZRX : Dontcallmeskaface, MoonRaccoon, TheDirtyTree
LINK : MoonRaccoon, TheDirtyTree
XLM : aeon, Bob
XRP: Dontcallmeskaface
任何真正擅长分类的人都可以帮我做这件事。。我对python真的很陌生,而且对一般的编码非常生疏
谢谢你的帮助
词典实际上无法进行排序,但为了便于打印,这是可以做到的
这将为您提供所需的输出
poll
中计算选票,获取d
d
结果:
这里有一条单行线:
输出:
要打印精美:
因为我真的很喜欢一行,一切都在一行强>
输出:
相关问题 更多 >
编程相关推荐