# Python 2 中字典(Dictionary) has_key() 函数用于判断键是否存在于字典中,
# 如果键在字典dict里返回true,否则返回false。
# 使用如下: dict.has_key(key)
dict = {'Name':'Python','Age':'28'} # 定义字典
print(dict.has_key('Name')) # True
print(dict.has_key('Age')) # False
Python 3 中字典(Dictionary) has_key() 函数变为 __contains__(key),用法一样:
dict = {'Name':'Python','Age':'28'} # 定义字典
print(dict.__contains__('Name')) # True