>>> d2 {'egg': 3, 'ham': {'grill': 4, 'fry': 6, 'bake': 5}, 'spam': 2} >>> d2.get('spamx',99) 99 >>> d2.get('ham')['fry'] 6
我想获得火腿里面的鱼苗值,如果没有,得到值,99或88作为第二个例子.但是怎么样?
python lookup dictionary default-value
default-value ×1
dictionary ×1
lookup ×1
python ×1