1.请求的url返回的是json代码,怎么提取里面的数据?
用response.text
如何加载response里面的数据?如果写的json.load(response.text)
则报错: File “/usr/lib/python2.6/json/init.py”, line 264, in load
return loads(fp.read(),
AttributeError: ‘str’ object has no attribute ‘read’
json.loads()解码python json格式
json.load()加载python json格式文件——加载时必须有相应的json文件,否则无法加载。
json.loads(response.text)
还是加载不了
出现weiboitem[‘MID’]=item[mid] String indices must be integers
首先看看response返回的东西是什么
所以加上response.text 再加上text里面的statues
学会断点调试,main.py然后debug,然后进入后台,并且查看变量
然后再看里面的变量,根据层级,去调试。