BK
Size: a a a
BK
СС
from functools import reduce
path1 = 'a.b.c'
path2 = 'a.b.e'
d = {'a': {'b': {'c': 13}}}
reduce(lambda x, y: x.get(y, None), path1.split('.'), d)
13
reduce(lambda x, y: x.get(y, None), path2.split('.'), d)
None
IS
from functools import reduce
path1 = 'a.b.c'
path2 = 'a.b.e'
d = {'a': {'b': {'c': 13}}}
reduce(lambda x, y: x.get(y, None), path1.split('.'), d)
13
reduce(lambda x, y: x.get(y, None), path2.split('.'), d)
None
IS
try:можно:
with open('action_item_id.txt', 'w') as outfile:
outfile.write(res.json()['model']['id'])
outfile.close()
except KeyError:
with open('action_item_id.txt', 'w') as outfile:
outfile.write(res.json()['active_action_item']['id'])
outfile.close()
data = res.json()
content = (data.get('model') or data.get('active_action_item'))['id']
with open('action_item_id.txt', 'w') as outfile:
outfile.write(content)
data.get('active_action_item'))['id']S
ИС
from functools import reduce
path1 = 'a.b.c'
path2 = 'a.b.e'
d = {'a': {'b': {'c': 13}}}
reduce(lambda x, y: x.get(y, None), path1.split('.'), d)
13
reduce(lambda x, y: x.get(y, None), path2.split('.'), d)
None
S
СС
СС
IS
S
BK
with open('action_item_id.txt', 'r') as outfile:
ai_id = outfile.read()
with open('comment_ai_id.txt', 'r') as outfile:
comment_ai_id = outfile.read()
with open('report_item_id.txt', 'r') as outfile:
report_item_id = outfile.read()BK
kostil = {
'first': action_item_id.txt
и т д
}BK
BK
M
ИС
with open('action_item_id.txt', 'r') as outfile:
ai_id = outfile.read()
with open('comment_ai_id.txt', 'r') as outfile:
comment_ai_id = outfile.read()
with open('report_item_id.txt', 'r') as outfile:
report_item_id = outfile.read()IS
with open('action_item_id.txt', 'r') as outfile:
ai_id = outfile.read()
with open('comment_ai_id.txt', 'r') as outfile:
comment_ai_id = outfile.read()
with open('report_item_id.txt', 'r') as outfile:
report_item_id = outfile.read()IS
BK