【发布时间】:2022-11-20 00:41:36
【问题描述】:
数据需要以这种格式存储
data = {'admin': [{'title': 'Register Users with taskManager.py', 'description': 'Use taskManager.py to add the usernames and passwords for all team members that will be using this program.', 'due date': '10 Oct 2019', 'date assigned': '20 Oct 2019', 'status': 'No'}, {'title': 'Assign initial tasks', 'description': 'Use taskManager.py to assign each team member with appropriate tasks', 'due date': '10 Oct 2019', 'date assigned': '25 Oct 2019', 'status': 'No'}], 'new user': [{'title': 'Take out trash', 'description': 'Take the trash can down the street', 'due date': '10 oct 2022', 'date assigned': '20 Oct 2022', 'status': 'No'}]}
我需要像这样显示这些数据:
user: admin
title: Register Users with taskManager.py
description: Use taskManager.py to add the usernames and passwords for all team members that will be using this program
date assigned: 10 Oct 2019
due date: 20 Oct 2022
status: No
title: Assign initial tasks
description: Use taskManager.py to assign each team member with appropriate tasks
date assigned: 10 Oct 2019
due date: 25 Oct 2019
status: No
user: new user
title: Take out trash
description: Take the trash can down the street
date assigned: 10 Oct 2022
due date: 20 Oct 202
status: No
我该怎么做呢?
【问题讨论】:
-
你试过什么了?发布脚本以显示您需要帮助的地方。您可以使用 for 循环迭代项目(键/值对),然后迭代列表的值。
标签: python list dictionary