为什么 dict.has_key() 在 Python 中不起作用?

Sai*_*ddy -2 dictionary python-2.x python-3.x

例子:

Dict={"Name":"Sai","Age":23}
"Age" in Dict
Run Code Online (Sandbox Code Playgroud)

产量TRUE,但是

Dict.has_key("Age")
Run Code Online (Sandbox Code Playgroud)

给出错误。这是为什么??

小智 7

has_keys()在 Python 3.x 中被删除

只是使用in仍然比has_keys()

源代码:https://docs.python.org/3.1/whatsnew/3.0.html#builtins