编程语言
首页 > 编程语言> > Python按关键字索引取dictionary.

Python按关键字索引取dictionary.

作者:互联网

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']}

标签:STATUS,SIGNATURES,dictionary,Python,RESERVATIONS,sublist,REPORTS,关键字,WOMEN
来源: https://www.cnblogs.com/gamecenter/p/11366548.html