← 返回题库
中级

生成银行账户月度对账单

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    customers_csv = open_url(____).read()
    accounts_csv = open_url(____).read()
    cards_csv = open_url(____).read()
    transactions_csv = open_url(____).read()
    transfers_csv = open_url(____).read()
    risk_rules_csv = open_url(____).read()
    import sqlite3
    import pandas as pd
    from io import StringIO

    conn = sqlite3.connect(____)
    pd.read_csv(StringIO(____)).to_sql(____)
    pd.read_csv(StringIO(____)).to_sql(____)

    txns = pd.read_sql_query(____)

    print(____)
    print(txns.to_string(____))

    income = txns[txns['____'].isin(____)]['____'].sum()
    expense = txns[txns['____'].isin(____)]['____'].sum()
    opening = txns.iloc[____]['____'] - txns.iloc[____]['____'] if txns.iloc[____]['____']=='____' else txns.iloc[____]['____'] + txns.iloc[____]['____']
    closing = txns.iloc[-____]['____']

    print(____)
    print(____)
    print(____)
    conn.close()

示例

输入
solve()
期望输出
=== 2025-04 对账单(账户1)===
      date     type  amount  balance_after
2025-04-01  deposit  5000.0        20230.5
2025-04-02 withdraw  1500.0        18730.5
2025-04-12  consume   800.0        17930.5
2025-04-15  consume  1200.0        16730.5
2025-04-30 interest  2000.0        18730.5
收入合计: 7000.00
支出合计: 3500.00
期末余额: 18730.50
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码