python dictionary note point

 

--from <fluent phthon> 

This is why modifying the contents of a dict while iterating through it is a bad idea. If you need to scan and add items to a dictionary, do it in two steps: read the dict from start to finish and collect the needed additions in a second dict. Then update the first one with it

posted @ 2019-02-26 05:14  happyran  阅读(194)  评论(0)    收藏  举报