{1: ['Antil', '(AR,82)', '(BIO2,71)', '(DAPA,64)', '(EXC,43)', '(SLIP,40)'], 2: ['Josh', '(CCN,82)', '(COC,49)', '(IAML,72)'], 3: ['Andry', '(ES,98)', '(TTS,97)']}
嗨,这是字典,我该如何在python中以以下格式将其打印出来,非常感谢
Antil-->(AR,82)(BIO2,71)(DAPA,64)(EXC,43)(SLIP,40)
Josh-->(CCN,82)(COC,49)(IAML,72)
Andry-->(ES,98)(TTS,97)
最佳答案
d = {1: ['Antil', '(AR,82)', '(BIO2,71)', '(DAPA,64)', '(EXC,43)', '(SLIP,40)'], 2: ['Josh', '(CCN,82)', '(COC,49)', '(IAML,72)'], 3: ['Andry', '(ES,98)', '(TTS,97)']}
for k,v in sorted(d.items()):
print("{0}-->{1}".format(v[0],''.join(v[1:])))
关于python - 如何在python中以这种方式打印字典,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33314704/