python json报错:AttributeError: 'str' object has no attribute 'read'
#!/usr/bin/python
#coding=gbk
import os
import json
Res='[{"brief":"ooooo","class_extid":13,"create_time":你好,"face_id":4,"flag":6777217,"flag_ext":0,"level":0,"max_member":100,"memo":"m~F~M0m~Zm~@~B","name":"10502","option":2,"ul":[{"flag":4,"u":285},{"flag":4,"u":35}]}]'
qDic = json.load(Res)
print qDic
for i in qDic:
print i["class_extid"]
print i["flag"]
for j in i["ul"]:
print str(j["flag"]) + "===" + str(j["u"])
执行后报错:
Traceback (most recent call last):
File "my.py", line 7, in <module>
qDic = json.load(Res)
File "/usr/lib/python2.6/json/__init__.py", line 264, in load
return loads(fp.read(),
AttributeError: 'str' object has no attribute 'read'
请高手指点,万分感谢
#coding=gbk
import os
import json
Res='[{"brief":"ooooo","class_extid":13,"create_time":你好,"face_id":4,"flag":6777217,"flag_ext":0,"level":0,"max_member":100,"memo":"m~F~M0m~Zm~@~B","name":"10502","option":2,"ul":[{"flag":4,"u":285},{"flag":4,"u":35}]}]'
qDic = json.load(Res)
print qDic
for i in qDic:
print i["class_extid"]
print i["flag"]
for j in i["ul"]:
print str(j["flag"]) + "===" + str(j["u"])
执行后报错:
Traceback (most recent call last):
File "my.py", line 7, in <module>
qDic = json.load(Res)
File "/usr/lib/python2.6/json/__init__.py", line 264, in load
return loads(fp.read(),
AttributeError: 'str' object has no attribute 'read'
请高手指点,万分感谢
...全文
相关推荐
python使用response.read()接收json数据的实例
今天小编就为大家分享一篇python使用response.read()接收json数据的实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
详解【python】str与json类型转换
主要介绍了【python】str与json类型转换,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
python将unicode和str互相转化的实现
主要介绍了python将unicode和str互相转化的实现,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
python将字典内容写入json文件的实例代码
在本篇文章里小编给大家整理的是一篇关于python将字典内容写入json文件的实例代码,有需要的朋友们可以参考下。
python读写json文件的简单实现
主要介绍了python读写json文件的简单实现,实例分析了各种读写json的方法和技巧,有兴趣的可以了解一下


