python some beautiful code

1:{ i:i for i in range(i)}

2:dict([(i,i) for i in range(i)])

# a = {'1': [1, 2, 5], '3': [6, 7], '2': [3, 4]}  --> {1: '1', 2: '1', 3: '2', 4: '2', 5: '1', 6: '3', 7: '3'}
{ x:i for i,j in monster_group.items() for x in j}

 

3:

 a = {'1': [1, 2, 5], '3': [6, 7], '2': [3, 4]}  --> {1: '1', 2: '1', 3: '2', 4: '2', 5: '1', 6: '3', 7: '3'}

posted on 2013-09-10 15:23  tiger4py  阅读(131)  评论(0)    收藏  举报

导航