参考 https://www.jb51.net/article/83108.htm ,修复了一点错误
def addTwoDimict(thedict, key_a, key_b, val):
if key_a in thedict:
thedict[key_a].update({key_b: val})
else:
thedict.update({key_a:{key_b: val}})
thedict = {}
addTwoDimict(thedict,'a','b',123)
print(thedict)
输出:
{'a': {'b': 123}}