擅长:python、mysql、java
<p>这是<code>data</code>的类型,对吗</p>
<pre><code>data: Dict[str, List[Dict[str, Dict[str, str]]]]
</code></pre>
<p>因此:</p>
<pre><code>data['athletes'][0]: Dict[str, Dict[str, str]]
data['athletes'][0:]: List[Dict[str, Dict[str, str]]]
</code></pre>
<p>当你切片<code>data['athletes']</code>(通过<code>[0:]</code>)时,你会得到<code>List</code>,你不能通过字符串索引它。当您得到一个特定的元素(通过<code>[0]</code>)时,您就得到了<code>List</code>中的第一个<code>Dict</code></p>
<p>其他答案已经建议如何打印姓名。如果你想把它们变成一个列表,下面是你如何通过理解来做到这一点(我认为这是你试图用切片来做的):</p>
<pre><code>names = [entry['athlete']['displayName'] for entry in data['athletes']]
</code></pre>