在python中经常遇到keyerror的问题 1.a={},a[2]+=3,会遇到keyerror的问题。但是如果a.setdefault(2, 0).问题就解决了。 转载于:https://www.cnblogs.com/hope100/p/4089545.html