简体   繁体   English

如何在python中以这种方式打印字典

[英]How to print the dictionary in this way in python

{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)']}

Hi, this is the dictionary, how can i print it out in the following format in python, thanks very much 嗨,这是字典,我该如何在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:])))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM