是否有任何 Python (Windows) 库来读取 PST 文件的内部目录结构,例如。收件箱、草稿等,包括用户创建的文件夹。
问问题
1470 次
1 回答
0
根据https://support.microsoft.com/en-us/kb/287070
Microsoft Outlook 自动将消息、联系人、约会、任务、便笺和日记条目存储在以下两个位置之一中: 在个人存储文件夹中,也称为 .pst 文件,位于您的硬盘驱动器上。在位于服务器上的邮箱中。如果您将 Outlook 与 Microsoft Exchange Server 一起使用,则您的邮箱位于服务器上。
因此,根据此信息,您应该能够使用操作系统
import os
该库的文档在这里:https ://docs.python.org/3/library/os.html
以下示例显示了 scandir() 的简单用法,以显示给定路径中不以“.”开头的所有文件(不包括目录)。entry.is_file() 调用通常不会进行额外的系统调用:
for entry in os.scandir(path):
if not entry.name.startswith('.') and entry.is_file():
print(entry.name)
用于验证目录:使用 listdir(path) 列出指定路径中的可用目录,添加更多逻辑,您应该能够实现您想要的 Ex:
import os
cdirs = os.listdir("C:/")
print(cdirs)
或创建一个函数来执行此操作:
def file_check(path):
file_dirs = listdir(path)
#do something with this
return file_dirs
于 2016-05-20T03:55:28.377 回答