2015-10-24 62 views
1
{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) 
+0

發表您的嘗試.. \ –

回答

4
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:])))