声明API结果响应

时间:2019-06-11 19:25:26

标签: python selenium

我如何断言生日== 1990-07-11?

Number

2 个答案:

答案 0 :(得分:0)

使用python的断言

d = { "count": 1, "results": [ { "birthDate": "1990-07-11", "cardNumber": "0QBD0040267646", "cellPhone": "(514) 333-4444", "city": "Brossard", "email": "farouk.rahem@bciti.com", } ], "start": 0, "success": True, "total": 1 }

assert d['results'][0]['birthDate'] == '1990-07-11'

您可以快速阅读有关Python中断言的tutorial

答案 1 :(得分:0)

这是一本字典,具有键results,该键是其他词典的列表,其中第一个具有键birthDate。因此:

assert myobject['results'][0]['birthDate'] == '1990-07-11'