【发布时间】:2020-10-01 14:30:36
【问题描述】:
我仅限于使用 python 2.7 来完成这项工作。
我想遍历 file_list 以查找哪些文件名包含任何 dict 值列表。
然后打印dict键和文件名。
## dictionary derived from opening and reading csv file
name_dict = {'kat': ['1', '2', '4'], 'rod': ['3', '7', '9'], 'tim': ['5', '6', '8']}
## list of files in a directory
file_list = ['1.pdf', '2.pdf', '3.pdf', '4.pdf', '5.pdf', '6.pdf', '7.pdf', '8.pdf', '9.pdf']
这是我在工作中自愿参与的一个项目,我是 python 新手。
真正让我困惑的是字典key:values 作为一个列表。
非常感谢任何帮助:-)
【问题讨论】:
标签: python list python-2.7 dictionary