首页 > 技术文章 > python字符串转字典

nicole-zhang 原文

import json

str_Detail = '{"rowOne":"A","rowTwo":"B","rowThree":"C"}'
print(str_Detail, type(str_Detail))
'''
{"rowOne":"A","rowTwo":"B","rowThree":"C"} <class 'str'>
'''
dict_Detail = json.loads(str_Detail)
print(dict_Detail, type(dict_Detail))
'''
{'rowOne': 'A', 'rowTwo': 'B', 'rowThree': 'C'} <class 'dict'>
'''

推荐阅读