首页 > 解决方案 > 如何使用 Python 3 检索 .msg 和 .MSG 文件?

问题描述

以下 Python 代码仅检索“.msg”文件

files = [f for f in os.listdir(path) if '.msg' in f]

如何添加它以便它也能检索“.MSG”文件?

标签: python-3.xoutlook

解决方案


files = [f for f in os.listdir(path) if '.msg' in f or '.MSG' in f]

您可以在列表理解中使用or和链接条件and


推荐阅读