擅长:python、mysql、java
<pre><code>>>> l = [{'term': u'Video Blogging', 'scheme': None, 'label': None}, {'term': u'blogging', 'scheme': None, 'label': None}, {'term': u'stuff', 'scheme': None, 'label': None}, {'term': u'Videos', 'scheme': None, 'label': None}]
>>> [a.get('term') for a in l]
[u'Video Blogging', u'blogging', u'stuff', u'Videos']
</code></pre>
<p>如果要以逗号分隔的字符串形式获取项目,请使用:</p>
<pre><code>>>> ', '.join(a.get('term') for a in l)
u'Video Blogging, blogging, stuff, Videos'
</code></pre>
<p>我使用<code>a.get('term')</code>而不是<code>a['term']</code>来避免没有<code>term</code>键的项使用<code>KeyError</code>。你知道吗</p>