Python按关键字索引取dictionary.
Posted gamecenter
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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‘]
以上是关于Python按关键字索引取dictionary.的主要内容,如果未能解决你的问题,请参考以下文章
Python 轻松解决从 K 个字符串数组中任意取一个字符串,按顺序拼接,列出所有可能的字符串组合。(对比用库和不用库的方法)
pandas.DataFrame设置某一行为表头(列索引),设置某一列为行索引,按索引取多行多列