← 返回题库
中级

实现存款操作(事务+流水记录)

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

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

    account_id, amount = ____, ____
    try:
        cur = conn.cursor()
        row = cur.execute("____", (____)).fetchone()
        new_balance = row[____] + amount
        cur.execute("____", (____))
        cur.execute(
            "____",
            (account_id, '____', amount, new_balance, '____', datetime.now().strftime(____))
        )
        conn.commit()
        print(____)
    except Exception as e:
        conn.rollback()
        print(____)

    new_bal = conn.execute("____", (____)).fetchone()[____]
    print(____)
    conn.close()

示例

输入
solve()
期望输出
存款成功
account_id=1 新余额: 20230.50
Python 代码 🔒 登录后使用
🔒

登录后即可练习

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