擅长:python、mysql、java
<p>要获取词典列表,请执行以下操作:</p>
<pre><code>features = ['Gender', 'DOB', 'Height']
your_objects = [Object1, Object2] # ...
list(map(lambda el: {f: getattr(el, f) for f in features}, your_objects))
</code></pre>
<p>因为您有很多对象,所以可以方便地遍历map对象,而不必将其强制转换为<code>list</code>。你知道吗</p>