为什么列表没有像字典那样安全的"获取"方法?
>>> d = {'a':'b'} >>> d['a'] 'b' >>> d['c'] KeyError: 'c' >>> d.get('c', 'fail') 'fail' >>> l = [1] >>> l[10] IndexError: list index out of range
python exception list indexoutofboundsexception
exception ×1
indexoutofboundsexception ×1
list ×1
python ×1