python 判断key是否在字典里

h={"c":"d","f":"a"}
print h
print type(h)
if 'a' in h:
    print '11111111'
else:
    print '22222222'
	
	
C:Python27python.exe C:/Users/TLCB/PycharmProjects/untitled/core/a26.py
{'c': 'd', 'f': 'a'}
<type 'dict'>
22222222



h={"c":"d","f":"a"}
print h
print type(h)
if 'c' in h:
    print '11111111'
else:
    print '22222222'
	
C:Python27python.exe C:/Users/TLCB/PycharmProjects/untitled/core/a26.py
{'c': 'd', 'f': 'a'}
<type 'dict'>
11111111
原文地址:https://www.cnblogs.com/hzcya1995/p/13349141.html