如何使用python从json中检索变量值

时间:2017-04-16 08:48:30

标签: python json

我有一个JSON文件,如下所示:

{"-Kh8M0qTdXJ-vBXr1G8v":{"email":"maad@yahoo.com","user":"amad"},"-Kh8M0v7KubmISGYrzks":{"email":"maad@yahoo.com","user":"amad"},"-KhB5OYsWias6j4Mc-pX":{"email":"faraz@yahoo.com","user":"faraz"},"-KhBBZ5Ii6kHPoUFhbj8":{"email":"zeeshan@gmail.com","user":"zeeshan"},"-KhBDTyGM9LaojajmtQv":{"email":"Ali@gmail.com","user":"Ali"}}

我想打印所有电子邮件和用户值。任何人都可以帮忙,我如何使用python从JSON获取这些值?

1 个答案:

答案 0 :(得分:0)

for d in json_dict.values():
    print(d['user'], ':', d['email'])

json_dict是你得到的json文件