問題 coverage-300615-dcit-python-loads・第1版

問題

JSON textからPython dict/listを得たい。使う操作はどれか。

  1. A 

    text.keys()をJSON文字列へ直接呼ぶ。

  2. B 

    json.loads(text)

  3. C 

    json.dumps(text)

正解:B

理由

JSON textをPython objectへdecodeする。

選択肢ごとの説明

A.

text.keys()をJSON文字列へ直接呼ぶ。

strにdictのkeys methodはない。

B.

json.loads(text)

JSON textをPython objectへdecodeする。

C.

json.dumps(text)

objectをJSON textへencodeする。

参考資料

お問い合わせ

演習する →