如何访问mrooney从Mint Scraper mintapi作为python字典返回的数据

2024-05-13 06:31:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我所指的薄荷刮刀是mrooney在github上发现的mintapihttps://github.com/mrooney/mintapi

我打电话的时候mint.get_预算()我如何获得具体的花费金额?在

例如,我将如何显示我在“食品和餐饮”上的花费

    #get budget data as json
    response = json.loads(.....)

    # Make the skeleton return structure
    budgets = {
        'income': response['data']['income'][
            str(max(map(int, response['data']['income'].keys())))
        ]['bu'],
        'spend': response['data']['spending'][
            str(max(map(int, response['data']['income'].keys())))
        ]['bu']
    }

    # Fill in the return structure
    for direction in budgets.keys():
        for budget in budgets[direction]:
            budget['cat'] = categories[budget['cat']]

    return budgets

Here是函数。在


Tags: theingithubjsondatagetreturnresponse
1条回答
网友
1楼 · 发布于 2024-05-13 06:31:16

以下是如何按类别访问特定支出金额

获取花费金额

    print(budget['spend'][0]['amt'])

要访问类别:

^{pr2}$

说明:

.get_budgets()返回包含两个键:值对,收入和支出

关键字“支出:”包含一个字典列表每个字典包含一个支出子类别,例如“食品和餐饮:食品杂货”

相关问题 更多 >