regex, . .
di = {
'resp': {
'frame': {
'html': {
'div': [
'test1'
]
}
}
}
}
import re
def check(k):
key = di.keys()
string = str(di.values())
if k in key:
return True
try:
m = re.findall('({[\"\']%s[\"\'])' % k, string)[0]
if m and re.match('{', m):
return True
else:
return False
except:
return False
for i in ['resp', 'abc', 'frame', 'div', 'yopy', 'python', 'test1']:
print i, check(i)
:
resp True
abc False
frame True
div True
yopy False
python False
test1 False