You cannot edit values directly, so you have to update a copy and then reset it:
import shelve
s = shelve.open("test")
s['flag'] = {}
temp = s['flag']
temp['foo'] = 'bar'
s['flag'] = temp
you cannot do
s['flag']['foo'] = 'bar'
directly because s['flag']
returns a copy
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…