資格スワイプ
データエンジニアリング基礎

Web APIからJSON形式のレスポンスを取得し、Pythonの辞書(dict)として扱いたい。requestsライブラリを用いたコードとして最も適切なものはどれか。

  • ✓response = requests.get(url); data = response.json()
  • Bresponse = requests.get(url); data = response.text
  • Cresponse = requests.get(url); data = response.content.decode()
  • Dresponse = requests.get(url); data = str(response)

解説

requestsのResponseオブジェクトが持つjson()メソッドは、レスポンス本文のJSON文字列を解析してPythonの辞書やリストに変換してくれる。

根拠データ分析試験 データエンジニアリング基礎:Web APIの利用

← 前の問題次の問題 →
スワイプでまとめて見る