-
Notifications
You must be signed in to change notification settings - Fork 0
/
hrml.py
56 lines (48 loc) · 1.27 KB
/
hrml.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
path = ""
dic = {}
td,tq = list(map(int,input().split(" ")))
while td:
td -= 1
thislinetokens = input()[1:-1].split(" ") # 去除 <> 并按照空格取出token ['hh', 'qwq=123', 'rew', '=', '345']
if thislinetokens == [""]: break
name = thislinetokens[0]
tokens = thislinetokens[1:]
if name[0] == '/':
path = path[:1-len(name)]
if path: path = path[:-1]
continue
# else
path += ("." if path else "") + name
i,length = 0,len(tokens)
"""
k=v k=v
k =v k,=v
k= v k=,v
k = v k,=,v
"""
while i < length:
#k=v; k=,v
if "=" in tokens[i]:
key,value = tokens[i].split("=")
if value == "":
value = tokens[i+1]
i+=1
else:
# k,=,v; k,=v
key,value = tokens[i],tokens[i+1]
i+=1
if value == "=":
value = tokens[i+1]
i+=1
elif value[0] == "=":
value = value[1:]
else:
pass # 合法 则不可能出现此情况
dic[path+"~"+key] = value
i += 1
# print(dic)
while tq:
tq -= 1
q = input()
if not q: break
print(dic.get(q,"Not found!"))