1. 程式人生 > >CCF Python題解(100分)201709-3 JSON查詢

CCF Python題解(100分)201709-3 JSON查詢

CCF Python題解(100分)201709-3 JSON查詢

# _*_ coding=utf-8 _*_
__author__ = 'SRF'
__date__ = '2018/8/26 15:37'
# r''都不會被轉義
import json

n, m = map(int, input().split())
str1 = ''
for i in range(n):
    str1 += input()
dict1 = json.loads(str1)
for j in range(m):
    keys = input().split('.')
    try:
        index =
0 dict2 = dict1 for index in range(len(keys)): if index == len(keys) - 1: value = dict2[keys[index]] else: dict2 = dict2[keys[index]] if type(value) != dict: print("STRING " + value) else: print
("OBJECT") except: print('NOTEXIST') continue