python3でstrからdictに変換する
import ast str = "{'name':'Taro', 'hieght':170}" type(str) => <class 'str'> dict = ast.literal_eval(str) type(dict) => <class 'dict'>
他の記事でast.literal_dict(str)
となっていたのですが、
AttributeError: module 'ast' has no attribute 'literal_dict'
とエラーになってしまったので、調べてみたら、literal_dictではなく、literal_evalでした。