在工作中我们经常会遇到数据类型之间的互转的问题,而通常我们请求一些API借口返回的结果就是字符串,但是格式是Json的,在Python中转为字典是最易处理的,所以这里记录一下在Python下把字符串转为字典的三种方法...Result:
input str info: __import__('os').system('ls')
collector_data.py
test.py
Download
dict_info is >0:
dict info type is -->:
使用json模块进行转换也存在一个问题,由于json语法规定 数组或对象之中的字符串必须使用双引号.../3.5/lib/python3.5/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0)...Versions/3.5/lib/python3.5/json/decoder.py", line 355, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError