Dictionary 是否含键值

#Python 3.X 里不包含 has_key() 函数,被 __contains__(key) 替代:

dict3 = {'name':'z','Age':7,'class':'First'};
print("Value : ",dict3.__contains__('name'))
print("Value : ",dict3.__contains__('sex'))


#执行结果:

Value :  True
Value :  False
发布了26 篇原创文章 · 获赞 1 · 访问量 1971

猜你喜欢

转载自blog.csdn.net/jiekaile/article/details/102872643