#先程のサンプルコードではdict_obj[key]というような形式で値を取得しましたが、get
#を利用する事もできます。

test_dict_1 = {'YEAR':'2010','MONTH':'1','DAY':'20'}

print(test_dict_1)

print('=============================')

print(test_dict_1['YEAR'])
# print(test_dict_1['YEARS'])

print('-----------------------------')

print(test_dict_1.get('YEAR'))
print(test_dict_1.get('YEARS'))

print('-----------------------------')

print(test_dict_1.get('YEAR','NOT FOUND'))
print(test_dict_1.get('YEARS','NOT FOUND'))
b630a51fd0ed8f56556cc48360c0f61b5e39b034
<mask token>

<mask token>
print(test_dict_1)
print('=============================')
print(test_dict_1['YEAR'])
print('-----------------------------')
print(test_dict_1.get('YEAR'))
print(test_dict_1.get('YEARS'))
print('-----------------------------')
print(test_dict_1.get('YEAR', 'NOT FOUND'))
print(test_dict_1.get('YEARS', 'NOT FOUND'))

test_dict_1 = {'YEAR': '2010', 'MONTH': '1', 'DAY': '20'}
print(test_dict_1)
print('=============================')
print(test_dict_1['YEAR'])
print('-----------------------------')
print(test_dict_1.get('YEAR'))
print(test_dict_1.get('YEARS'))
print('-----------------------------')
print(test_dict_1.get('YEAR', 'NOT FOUND'))
print(test_dict_1.get('YEARS', 'NOT FOUND'))

#先程のサンプルコードではdict_obj[key]というような形式で値を取得しましたが、get
#を利用する事もできます。

test_dict_1 = {'YEAR':'2010','MONTH':'1','DAY':'20'}

print(test_dict_1)

print('=============================')

print(test_dict_1['YEAR'])
# print(test_dict_1['YEARS'])

print('-----------------------------')

print(test_dict_1.get('YEAR'))
print(test_dict_1.get('YEARS'))

print('-----------------------------')

print(test_dict_1.get('YEAR','NOT FOUND'))
print(test_dict_1.get('YEARS','NOT FOUND'))