回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我从不同的API请求数据。它们都提供了相似的信息,但它们提供的输出在结构上略有不同。每个输出都包含在字典列表中,但组织和结构不同。一个输出可以是一个列表,其中包含一个字典、多个字典以及另一个字典的值</p>
<p>这里我展示了一个示例输出</p>
<pre><code>[{'allele_string': 'G/A',
'transcript_consequences': [{'protein_end': 663,
'gene_symbol_source': 'HGNC',
'protein_start': 663,
'gene_symbol': 'MYH7',
'amino_acids': 'R/H',
'codons': 'cGc/cAc',
'biotype': 'protein_coding',
'hgnc_id': 'HGNC:7577',
'cds_end': 1988,
'cds_start': 1988,
'polyphen_score': 0.782,
'transcript_id': 'ENST00000355349',
'cdna_start': 2093,
'impact': 'MODERATE',
'consequence_terms': ['missense_variant'],
'variant_allele': 'A',
'cdna_end': 2093,
'sift_score': 0.06,
'gene_id': 'ENSG00000092054',
'sift_prediction': 'tolerated',
'polyphen_prediction': 'possibly_damaging',
'strand': -1}],
'input': 'NM_000257.3:c.1988G>A',
'start': 23426833,
'end': 23426833,
'colocated_variants': [{'phenotype_or_disease': 1,
'allele_string': 'HGMD_MUTATION',
'strand': 1,
'id': 'CM993620',
'seq_region_name': '14',
'end': 23426833,
'start': 23426833},
{'allele_string': 'C/T',
...
</code></pre>
<p>独立于字典列表的结构,我需要获得例如键“gene_symbol”和“allege_string”的值。这些值可以在列表的第一个字典中,也可以在最后一个字典中,或者在另一个字典中的字典中。所以我认为我需要的是逐键读取完整列表,找到我要查找的键,然后将其值保存在一个变量中</p>
<pre><code>gene_symbol = 'value_found'
</code></pre>
<p>这是最好的方法吗?我该怎么做</p>