疑问:
-
如何把类似json的字符串转换为python的字典类型?
解答:
- 代码
-
word = '{"name":"123"}' import json try: res = json.loads(word) except json.decoder.JSONDecodeError as e: print("出现错误",e) else: print(type(res),res)
如何把类似json的字符串转换为python的字典类型?
word = '{"name":"123"}' import json try: res = json.loads(word) except json.decoder.JSONDecodeError as e: print("出现错误",e) else: print(type(res),res)