
1 jayjing OP 已经解决,感谢。 |
3 957204459 2017 年 8 月 10 日 via iPhone 对,怎么不写出怎么解决的? |
4 Finest 2017 年 8 月 10 日 message\\ 这个就有问题了吧 |
5 mxmai 2017 年 8 月 10 日 ``` import json with open('D:/data/py/data/3.json') as f: src = f.readline() s = src.decode('string-escape').strip('"') d = json.loads(src) print s print type(d) ``` 数据被转义了。 * https://stackoverflow.com/questions/22600128/json-loads-is-returning-a-unicode-object-instead-of-a-dictionary |
6 jayjing OP b = json.loads(a) 后发现 b 被存为 unicode 类型 需要转成 dict 类型才能读取出来,这里遇到困难了,怀疑是我的 json 格式不对 导致识别不了 dict 最后放弃了这个方法。 后面我是用 json 保存为 txt 用 re.findall 取我要的字符串。 |
7 strict 2017 年 8 月 10 日 null 跟 true 都不是 python 对象啊,怎么 loads 出来?,我很疑惑 |
8 hellove1985 2017 年 8 月 10 日 @strict 这两个有什么关系,为什么不能 loads 出来?,我很疑惑 |
9 strict 2017 年 8 月 10 日 @hellove1985 这个我理解错了,我以为 json 当中的值只能是字符串,其实也可以是 ture,false,null |
10 mingyun 2017 年 8 月 10 日 发现 json.loads 后 null 变成了 None |