回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我有以下代码。你知道吗</p>
<pre><code>import os
products = [
{"Product": "S65-85OS04_M2M_GP211_JC222_R6",
"PlatformName": "winPc",
"PlatformVariant": "eeprom",
"DocGeneration": False,
"BuildStatus": "Pass",
},
{"Product": "SC5-01OS19_GP221_JC302_LTE_MTN",
"PlatformName": "winPc",
"PlatformVariant": "flash",
"DocGeneration": False,
"BuildStatus": "Fail",
},
{"Product": "SC5-01OS01_GP211_JC302_LTE_TMO",
"PlatformName": "winPc",
"PlatformVariant": "flash",
"DocGeneration": False,
"BuildStatus": "Pass",
}
]
class UTE(object):
def __init__(self, workspace, products, blackList=None):
for each in products:
# print each
if each['Product'] in blackList:
products.remove(each)
for each in products:
print each["Product"]
if __name__ == '__main__':
ins = UTE('ws', products, ["SC5-01OS01_GP211_JC302_LTE_TMO", "SC5-01OS19_GP221_JC302_LTE_MTN"])
</code></pre>
<p>现在每当我运行它时,它只删除dict中的一个条目。例如,在本例中,它删除的是第二个条目,即<code>SC5-01OS19_GP221_JC302_LTE_MTN</code>。我相信这和浅拷贝有关。<strong>我说的对吗??</strong>如果没有,那么如何解决这个问题?你知道吗</p>