日期时间到文件时间 (Python)

jer*_*emy 6 python datetime filetime

有什么链接可以让我使用 python 将日期时间转换为文件时间吗?

示例:2011 年 4 月 13 日 07:21:01.0874 (UTC) FILETIME=[57D8C920:01CBF9AB]

从电子邮件标题中获取上述内容。

Pil*_*ill 1

我在重复问题中的答案被删除,所以我将在这里发布:
冲浪我发现了这个链接:http ://cboard.cprogramming.com/windows-programming/85330-hex-time-filetime.html

之后,一切都变得简单:

>>> ft = "57D8C920:01CBF9AB"
... # switch parts
... h2, h1 = [int(h, base=16) for h in ft.split(':')]
... # rebuild
... ft_dec = struct.unpack('>Q', struct.pack('>LL', h1, h2))[0]
... ft_dec
... 129471528618740000L
... # use function from iceaway's comment
... print filetime_to_dt(ft_dec)
2011-04-13 07:21:01
Run Code Online (Sandbox Code Playgroud)

调整它是由你决定的。