python is determined whether there is a key dictionary

Example: a dictionary generating #
d = { 'title': ' abc', 'age': 18}


IF 'title' in d.keys ():
  Print ( 'present')
the else:
  Print ( 'absent')

 

IF 'title' Not in d.keys ():
  Print ( 'not present')
the else:
  Print ( 'present')

Guess you like

Origin www.cnblogs.com/WebLinuxStudy/p/12024666.html