Python nested dict comprehension

后端 未结 1 676
太阳男子
太阳男子 2021-01-20 09:13

Can someone explain how to do nested dict comprehensions?

>> j = dict(((x+y,0) for x in \'cd\') for y in \'ab\')
>> {(\'ca\', 0): (\'da\', 0), (\         


        
1条回答
  •  醉话见心
    2021-01-20 09:41

    dict((x+y,0) for x in 'cd' for y in 'ab')
    

    0 讨论(0)
提交回复
热议问题