2015-11-07 76 views
0

如何[同]富添加到字典中,使得加富到辭典鍵

a = {'continent': ['America', 'South Africa'], 'country': ['USA', 'Egypt']} 

的所有按鍵變爲:

a = {'foo(bar=continent, hello=world)': ['America', 'South Africa'], 'foo(bar=country, hello=world)': ['USA', 'Egypt']} 

編輯: 我其實希望編輯海峽關鍵非STR關鍵,所以:

a = {foo(bar='continent', hello=world): ['America', 'South Africa'], foo(bar='country', hello=world): ['USA', 'Egypt']} 
+1

Unrelate但南非不是一個大陸 –

回答

4
a = {'foo(bar=' + key + ', hello=world)': a[key] for key in a.keys()}