相关疑难解决方法(0)

从请求库解析JSON响应的最佳方法是什么?

我正在使用python requests模块向服务器发送RESTful GET,我在JSON中得到响应.JSON响应基本上只是一个列表列表.

强制响应本机Python对象的最佳方法是什么,所以我可以使用迭代或打印出来pprint

python rest json python-requests

232
推荐指数
3
解决办法
39万
查看次数

TypeError:'dict'对象不可调用

我正在尝试循环输入字符串的元素,并从字典中获取它们.我究竟做错了什么?

number_map = { 1: -3, 2: -2, 3: -1, 4: 1, 5: 2, 6: 3 }
input_str = raw_input("Enter something: ")
strikes = [number_map(int(x)) for x in input_str.split()]
Run Code Online (Sandbox Code Playgroud)
strikes  = [number_map(int(x)) for x in input_str.split()]
TypeError: 'dict' object is not callable
Run Code Online (Sandbox Code Playgroud)

python dictionary

39
推荐指数
6
解决办法
23万
查看次数

标签 统计

python ×2

dictionary ×1

json ×1

python-requests ×1

rest ×1