Python dictionary get () method

Python dictionary get () method

If we need to get the value of the dictionary, we have two ways, one is through dict [ 'key'], the other one is dict.get () method

Example:

D = {'Name': 'Tony', 'Age': 27}
print ("Age 值为 : %s" %  D.get('Age'))

operation result:

Age 值为 : 27
Published 11 original articles · won praise 0 · Views 111

Guess you like

Origin blog.csdn.net/qq_34172780/article/details/104965053