我正在尝试一个代码块来处理一个特定的异常: my_dict.get(s)
print("This key does not exist inthe dictionary")else:这是函数的一部分,其中's‘是函数的一个参数。它工作良好,并在try块不引发异常时打印与键对应的值。
但是当它出现时,我无法得到
Please enter who you're looking for, or type 'quit' to get out: ").split() print "%s's%s is %s" % (response[0], response[1], people[response[0]][response[1]])
except KeyError:'Mary phone'