擅长:python、mysql、java
<p>将功能名称词典保持为布尔启用/禁用。这比让所有这些变量浮动要好得多。在</p>
<pre><code>def __init__(self, **kwargs):
self.features = kwargs
def getFeatures(self):
return {feature for feature, isEnabled in self.features.items() if isEnabled}
</code></pre>
<hr/>
<p>示例:</p>
^{pr2}$