dics.get(k,d)get相当于一条if...else...语句。如果参数k在字典dics中,字典将返回dics[k];返回参数d。例子 >>> l = {4:1, 3:1} >>> l.get(2, \'a\') \'a\' >>> l.get(4, \'a\') 1 相关文章: