Posted in Python onJanuary 28, 2014
需求:['1:a','2:b','3:c'] 转换为 {'1′: 'a','3′: 'c','2′: ''}
a = {} b = ['1:a','2:b','3:c'] map(lambda x:a.setdefault(x.split(':')[0], x.split(':')[1]), b) print a {'1': 'a', '3': 'c', '2': 'b'}
python list转dict示例分享
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@