擅长:python、mysql、java
<p>所有属性都可以作为字典在对象的<code>__dict__</code>属性中找到(键->属性名称,值->属性值)。您可以通过列表理解和筛选未初始化的属性来筛选未初始化的变量:</p>
<pre><code>def get_initialized_attrs(self):
return [elem for elem in self.__dict__.values() if elem != None]
</code></pre>
<p>您可能还希望收集具有特定类型的属性,例如字符串(<code>"str"</code>)、整数(<code>"int"</code>)等:</p>
^{pr2}$