我在python中有跟随词:
<scrip>
angular.module('mainApp', ['subModule1', 'subModule2']);
angular.module('subModule1')
.controller('MyController', ['$scope', function($scope) {
$scope.moduleName = 'subModule1';
}]);
</script>
...
<div ng-app="mainApp">
<div ng-controller="MyController">
<span ng-bind="moduleName"></span>
</div>
现在我要删除值“DEF”,但将其保留为Key。 所以它将是:
d = {'ABC': ["DEF", "ASD"], 'DEF': ["AFS", "UAP"]}
答案 0 :(得分:0)
试试这个?
for name, datalist in d.iteritems(): # Or items() in Python 3.x
for datadict in datalist:
for key, value in datadict.items():
if value == "AAA":
datadict[key] = ""
这有用吗?
答案 1 :(得分:0)
d = {'ABC': ["DEF", "ASD"], 'DEF': ["AFS", "UAP"]}
val_to_del = "DEF"
for key in d:
if val_to_del in d[key]:
d[key].remove(val_to_del)
print(d)