码迷,mamicode.com
首页 > 编程语言 > 详细

Python按关键字索引取dictionary.

时间:2019-08-16 23:10:02      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:ret   member   pretty   mina   ESS   status   signature   str   sub   

AST = [‘AGENDA‘],["WOMEN‘S STATUS", ‘TREATIES‘,
‘SIGNATURES, ACCESSIONS, RATIFICATIONS‘,
‘RESERVATIONS AND DECLARATIONS‘,
‘GENDER DISCRIMINATION‘], [‘ELECTION OF MEMBERS‘,
‘BIOGRAPHY‘], [ "WOMEN‘S RIGHTS",
"WOMEN‘S STATUS",
‘PERIODIC REPORTS‘]"


最后采用
>>> {idx: sublist for idx, sublist in enumerate(AST, 1)}
{1: [‘AGENDA‘],
 2: ["WOMEN‘S STATUS", ‘TREATIES‘, ‘SIGNATURES, ACCESSIONS, RATIFICATIONS‘, ‘RESERVATIONS AND DECLARATIONS‘, ‘GENDER DISCRIMINATION‘],
 3: [‘ELECTION OF MEMBERS‘, ‘BIOGRAPHY‘],
 4: ["WOMEN‘S RIGHTS", "WOMEN‘S STATUS", ‘PERIODIC REPORTS‘]}

Python按关键字索引取dictionary.

标签:ret   member   pretty   mina   ESS   status   signature   str   sub   

原文地址:https://www.cnblogs.com/gamecenter/p/11366548.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!