- 积分
- 451
- 鸿鹄币
- 个
- 好评度
- 点
- 精华
- 注册时间
- 2017-11-3
- 最后登录
- 1970-1-1
- 阅读权限
- 30
- 听众
- 收听
初级工程师
|
根据题库第592题,请问答案是 A 还是 B? 在其他网站看到是 A,论坛里的题库答案是 B。
- {+ O' W. A- C! g; K7 f0 c$ G9 |3 J- {$ m
Based on the router's API output in JSON format below, which Python code will display the value of the "hostname"key?( f' l- u7 N, K) b) e+ z Q3 q
{
$ ]- ]" g/ b8 c "response":[{ [/ `; P) Q6 s- Q- n: i+ j) j
"family": "Switches",5 R& v& Q# x; `4 k) Y; R" \ R
"macAddress": "00:41:49:45:76:00"," Y# \. @' W. W) O% U
"hostname": "SwitchIDF14",, @$ A; i0 r" o {( g& Z7 w9 V
"upTime": "352 days, 6:17:26:10",* @1 m( R# M4 v
"lastUpdated": "2020-07-12 21:15:29"
# I4 O& p% E6 S+ H1 i/ e ]}
, V' f4 A% t! q4 o0 }6 _}
" ?' q+ h: e8 O& V# [" e( w/ k; ~, P" f( p6 H! q
A. json_data= json.loads(response.text)& R2 l, Y8 Y/ r& p/ P
print(json_data['response']['family'][hostname]& W3 d5 @3 w7 o* G, w) R3 N
: }0 V5 b2 u0 O1 l- ?B. json_data= response.json()
+ E2 ?/ n. m# ]* |3 u print(json_data['response'][0]['hostname']
; s; w- i- T: E% ~& L( g/ I: G' l) o6 O, a$ _
/ K) e. P- v* z" Y
|
|