I have a collections.defaultdict
as follows:
mydict = defaultdict(lambda:0)
mydict['stock1'] = 1.11
mydict['stock2'] = 2.22
mydict['stock3'] = 3.33
Now I want to remove the second item completely, how can I do that?
Maybe there is little seens to remove that but just simply set it to zero as follow:
mydict['stock2'] = 0
See the documentation , it's just like the ordinary dictionary. You can use either:
del mydict['stock2']
mydict.pop('stock2')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.