【发布时间】:2021-05-15 01:22:42
【问题描述】:
我是 Python 新手..
我可以通过将两个字典与dictdiffer 进行比较来生成以下输出,它位于oo 变量中:
oo = ('remove', '', [('we are here to help you improve your skills', [['2021-04-09', 'email@example.com', 'we are here to help you improve your skills', 'Delivered']]), ('(1st meeting) here is our recorded presentation skills webinar', [['2021-04-12', 'email@example.com', '(1st meeting) here is our recorded presentation skills webinar', 'Delivered']]), ('YOU ARE INVITED TO THIS PROGRAMMING EVENT', [['2021-04-13', 'email@example.com', 'YOU ARE INVITED TO THIS PROGRAMMING EVENT', 'Delivered'], ['2021-04-16', 'email@example.com', 'YOU ARE INVITED TO THIS PROGRAMMING EVENT', 'Delivered']])])
('remove', '', [('we are here to help you improve your skills', [['2021-04-09', 'email@example.com', 'we are here to help you improve your skills', 'Delivered']]), ('(1st meeting) here is our recorded presentation skills webinar', [['2021-04-12', 'email@example.com', '(1st meeting) here is our recorded presentation skills webinar', 'Delivered']]), ('YOU ARE INVITED TO THIS PROGRAMMING EVENT', [['2021-04-13', 'email@example.com', 'YOU ARE INVITED TO THIS PROGRAMMING EVENT', 'Delivered'], ['2021-04-16', 'email@example.com', 'YOU ARE INVITED TO THIS PROGRAMMING EVENT', 'Delivered']])])
('remove', '', [('we are here to help you improve your skills', [['2021-04-09', 'email@example.com', 'we are here to help you improve your skills', 'Delivered']]), ('(1st meeting) here is our recorded presentation skills webinar', [['2021-04-12', 'email@example.com', '(1st meeting) here is our recorded presentation skills webinar', 'Delivered']]), ('YOU ARE INVITED TO THIS PROGRAMMING EVENT', [['2021-04-13', 'email@example.com', 'YOU ARE INVITED TO THIS PROGRAMMING EVENT', 'Delivered'], ['2021-04-16', 'email@example.com', 'YOU ARE INVITED TO THIS PROGRAMMING EVENT', 'Delivered']])])
我想访问 此元组中的列表,输出如下:
['2021-04-09', 'email@example.com', 'we are here to help you improve your skills', 'Delivered']
['2021-04-12', 'email@example.com', '(1st meeting) here is our recorded presentation skills webinar', 'Delivered']
['2021-04-13', 'email@example.com', 'YOU ARE INVITED TO THIS PROGRAMMING EVENT', 'Delivered']
......
......
到目前为止我所做的只是looping by index value:
for tuple in enumerate(oo):
for list in tuple[1]:
for activity in list:
print(activity[0])
但是输出是随机字母,并不是每个列表(以日期开头)都在那里!:
r
e
m
o
v
e
w
['2021-04-09', 'email@example.com', 'we are here to help you improve your skills', 'Delivered']
(
['2021-04-12', 'email@example.com', '(1st meeting) here is our recorded presentation skills webinar', 'Delivered']
Y
['2021-04-13', 'email@example.com', 'YOU ARE INVITED TO THIS PROGRAMMING EVENT', 'Delivered']
如何排列列表并从这个多元组变量中检索它们?
【问题讨论】:
标签: python python-3.x list tuples