第26367题 单选题
补全Python实现实验室物品领用记录追加与查看功能的代码

假设你管理一个实验室,需要记录物品的领用情况。每次领用时,你会记录下领用的日期、物品名称以及领用人的姓名。这个信息将被保存在一个名为lab_issuance.txt的文本文件中。其要求如下:①在文件末尾追加新的物品领用记录;②可以查看当前所有的物品领用记录。请在下面程序空白处填上正确内容以实现程序功能。

def append_record(date, item, name):
    with open("lab_issuance.txt", ____________) as file: # 填写代码 ①
    file.write(f"{date},{item},{name}\n")

def read_records():
    with open("lab_issuance.txt", "r") as file:
        records = ____________ # 填写代码 ②
        for record in records:
            print(record, end="")

# 示例操作
append_record("2024-11-05", "Computer", "Tom")
append_record("2024-11-06", "Pen", "Jack")
read_records()
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析