「Python入門」辞書のgetメソッドでキーから値を取得する

Pythonコード
>>> dct = {'Name’: 'Alice’, 'Age’: 18, 'uid’: 1001, 'id’: 1001}
>>> def get_value2(dct, key):
return dct.get(key, “Key Not Exist!")
>>> get_value2(dct, “uid")
1001
>>> get_value2(dct, “UID")
'Key Not Exist!’

Python

Posted by arkgame