dict.has_key(key)
key -- 這是在在字典中搜尋的鍵。
#!/usr/bin/python3 dict = {'Name': 'Zara', 'Age': 7} print ("Value : %s" % dict.has_key('Age')) print ("Value : %s" % dict.has_key('Sex'))
Value : True Value : False