我如何通过其中包含字典的列表迭代,必须对一个密钥的值进行ietration
我想浏览所有“文件名”键以阅读它。例如,我想阅读'20220214T132301560.jpg'喜欢其中的所有JPG文件。 我该怎么做?
list=[{'convertedDate': '2022-02-14 13:23:01.560000',
'filename': '20220214T132301560.jpg'},
{'convertedDate': '2022-02-14 13:23:03.840000',
'filename': '20220214T132303840.jpg'},
{'convertedDate': '2022-02-14 13:23:07.860000',
'filename': '20220214T132307860.jpg'}]
I want to go through all 'filenames' keys to read it. For example i want to read '20220214T132301560.jpg' like this all jpg files in it.
how shall i do that?
list=[{'convertedDate': '2022-02-14 13:23:01.560000',
'filename': '20220214T132301560.jpg'},
{'convertedDate': '2022-02-14 13:23:03.840000',
'filename': '20220214T132303840.jpg'},
{'convertedDate': '2022-02-14 13:23:07.860000',
'filename': '20220214T132307860.jpg'}]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您试图访问所有
文件名
值:If you are trying to access all of the
filename
values:如果该文件名与您的所需值匹配,则将返回列表中的DICT条目:
结果:
{'convertedDate':'2022-02-14 13:23:01.560000','filename':'20220214T132301560.jpg'}
注:请勿使用
list
作为变量名称。它是一种类型名称,保留在Python中。This will return the dict entry in your list if it's filename matches your desired value:
RESULT:
{'convertedDate': '2022-02-14 13:23:01.560000', 'filename': '20220214T132301560.jpg'}
Notes: Do not use
list
as a variable name. It is a type name, reserved in Python.