- 积分
- 451
- 鸿鹄币
- 个
- 好评度
- 点
- 精华
- 注册时间
- 2017-11-3
- 最后登录
- 1970-1-1
- 阅读权限
- 30
- 听众
- 收听
初级工程师
|
根据题库第592题,请问答案是 A 还是 B? 在其他网站看到是 A,论坛里的题库答案是 B。
9 @) ^* H' } e' ?2 n/ z S7 Y9 h3 d9 P) q
Based on the router's API output in JSON format below, which Python code will display the value of the "hostname"key?5 N- e0 @- V0 B. s
{) e$ N4 I1 U! A# I
"response":[{
1 o9 y: R& Q3 A9 F0 w+ P8 {8 g "family": "Switches",
( A# o: K) f# S" i "macAddress": "00:41:49:45:76:00",; P; x! w; N8 y" j/ N4 N/ W
"hostname": "SwitchIDF14",
5 |( R/ O9 ~) m) l3 I "upTime": "352 days, 6:17:26:10",7 Y+ {0 g( j) m/ {. |! S
"lastUpdated": "2020-07-12 21:15:29"
) E, s4 e' _0 k; O1 U. x/ ]% B ]}7 b7 O- J" O: v
}% n$ |% c, `# k1 H' Z
W. m$ l2 i! r, M$ v/ H
A. json_data= json.loads(response.text)
6 G# @( P' t" L% d2 n5 M6 f1 C print(json_data['response']['family'][hostname]6 u4 ]8 L/ z) x, S! \
/ L/ d5 m/ z5 R+ e% T( n* [$ RB. json_data= response.json()
+ f7 Y$ A# i) j! M& Q& I- \ print(json_data['response'][0]['hostname']' \0 d# g' R0 B3 E+ T
) Q) V. P& q# ?# {8 p. @2 u# b/ g
/ h( k" ?7 ~( t$ S. J) ~- `4 j |
|