python-3.x - 如何通过 Python 和 pytest 获取 dict “Current”
问题描述
现在我写了这段代码
r = requests.get(BET.format())
a = json.loads(r.text)
print(a)
我收到所有 json 响应的地方。而不是需要获取“当前”来解析值,使用 python 和 pytest:
{
"command": "bet",
"status": "ok",
"game": {
"current": {
"lines": 25,
"bet": 10,
"state": "idle",
"transitions": [
"bet"
]
},
"symbols": {
"symbols": [
[
2,
2,
5
],
[
2,
2,
10
],
[
9,
9,
9
],
[
6,
2,
2
],
[
6,
5,
8
]
解决方案
"current"
您可以使用上面的 dict 文字访问与键关联的值a['game']['current']
。
推荐阅读
- javascript - ReferenceError:找不到变量:False - React Native(Hookstate)
- angular - 如何创建一个本身调用 HTTP 方法的可观察方法
- zappa - 是否有将一些记录器消息发布到单独的 Cloudwatch 日志组?
- python - 两个列表的产品的所有唯一组合
- python - 如何测试数组(dtype 对象)中的空白?
- angular - Ngmodel 表单验证
- node.js - nodejs pdf解析在特定字符串后获取值
- svg - svg - 拐角不像预期的那样锋利
- javascript - node.js express 和正则表达式
- python - 输入1个数字后如何使代码不结束?