gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-30 03:07:02 24 4
gpt4 key购买 nike

是否有使用 python 将日期时间转换为文件时间的链接?

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

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

最佳答案

我在重复问题中的回答被删除了,所以我会在这里发布:
四处冲浪我发现了这个链接: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

调整它由您决定。

关于python - 日期时间到文件时间 (Python),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6408077/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com