![](https://i-blog.csdnimg.cn/blog_migrate/214fc98fa6ecf8874505d53252367173.png)
![](https://i-blog.csdnimg.cn/blog_migrate/07655dbe67413b13498ef3a7f2c2f990.png)
dir_date1 = {
'鲫鱼': [18, 10.5],
'鲤鱼': [8, 6.2],
'鲢鱼': [7, 4.7]
}
dir_date2 = {
'草鱼': [2, 7.2],
'鲫鱼': [3, 12],
'黑鱼': [6, 15]
}
dir_date3 = {
'乌龟': [1, 71],
'鲫鱼': [1, 9.8],
'草鱼': [5, 7.2],
'黄鱼': [2, 40]
}
fish_records = {
'1月1日': dir_date1,
'1月2日': dir_date2,
'1月3日': dir_date3
}
# 钓鱼总数量
total_nums = 0
# 钓鱼总金额
total_amount = 0
# 日期记录
day = ''
# 每天钓鱼记录
day_record = {}
fish_del_name = '黄鱼'
fish_date, fish_reduce_name = '1月1日', '鲫鱼'
fish_day_date = '1月3日'
for day, day_record in fish_records.items():
print(f'{day}钓鱼记录为:')
# 保存修改之后的记录
records_to_keep = {}
for fish_name, fish_subrecords in day_record.items():
# 删除黄鱼
if not fish_name == fish_del_name:
records_to_keep[fish_name] = fish_subrecords
# print(records_to_keep)
# 删减一条鱼
if day == fish_date:
for fish_name, fish_subrecords in records_to_keep.items():
if fish_name == fish_reduce_name:
fish_subrecords[0] -= 1
break
records_to_keep[fish_name] = fish_subrecords
if day == fish_day_date:
for fish_name, fish_subrecords in records_to_keep.items():
fish_subrecords[1] = fish_subrecords[1] * 1.1
records_to_keep[fish_name] = fish_subrecords
day_record.clear()
day_record.update(records_to_keep)
for fish_name, fish_subrecords in day_record.items():
total_nums += fish_subrecords[0]
total_amount += fish_subrecords[0] * fish_subrecords[1]
print(f'\t{fish_name}数量{fish_subrecords[0]},单价{fish_subrecords[1]:.2f}元')
print(f'钓鱼总数量为{total_nums},总金额为{total_amount:.2f}元')