nerdexam
Huawei

H12-891_V1.0 · Question #342

the print(r.json()) command in the Python script , and the print output is as follows: {'data': [{'token_id': 'x-eonsfw', 'expiredDate': 2020-07-07 07:30:00', 'errcode': '0', 'errmsg': get token…

The correct answer is A. id=r.json (['data']['token_id']. See the full explanation below for the reasoning.

SDN and Network Automation

Question

the print(r.json()) command in the Python script , and the print output is as follows:

{'data': [{'token_id': 'x-eonsfw', 'expiredDate': 2020-07-07 07:30:00', 'errcode': '0', 'errmsg': get token successfully'} The output contains multiple elements. Now we need to filter out the value of token_id and assign it to the variable id. Which of the following is the correct command?

Options

  • Aid=r.json (['data']['token_id']
  • Bid=r.json()('data')('token_id')
  • Cid=r.json(){'data'} {'token_id'}
  • Did=r.json()('token_id')

How the community answered

(29 responses)
  • A
    76% (22)
  • B
    7% (2)
  • C
    3% (1)
  • D
    14% (4)

Topics

#Python#REST API#JSON parsing#network automation

Community Discussion

No community discussion yet for this question.

Full H12-891_V1.0 Practice