创建由Monday到Sunday的七个值组成的字典,输出建列表、值列表及键值列表
时间: 2023-12-14 19:38:10 浏览: 85
Python 输出时去掉列表元组外面的方括号与圆括号的方法
可以使用以下代码创建由Monday到Sunday的七个值组成的字典,并输出建列表、值列表及键值列表:
```python
week_dict = {"Monday": 1, "Tuesday": 2, "Wednesday": 3, "Thursday": 4, "Friday": 5, "Saturday": 6, "Sunday": 7}
keys = list(week_dict.keys())
values = list(week_dict.values())
items = list(week_dict.items())
print("Keys: ", keys)
print("Values: ", values)
print("Items: ", items)
```
输出结果为:
```
Keys: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
Values: [1, 2, 3, 4, 5, 6, 7]
Items: [('Monday', 1), ('Tuesday', 2), ('Wednesday', 3), ('Thursday', 4), ('Friday', 5), ('Saturday', 6), ('Sunday', 7)]
```
阅读全文