requests请求后,response.text打印后是一个形似dict的东西,打印其类型,发现为Unicode类型。
此时若直接将其当做dict来索引,会报错 TypeError:string indices must be integers
解决此问题,需要先将Unicode类型的数据转换成 string,在用json.load()将其转换成dict。
result = response.text.encode("utf8")
result = json.loads(result)