对于Windows上的os.path.getmtime(),Python2.4和2.6的行为有所不
发布时间:2020-12-14 05:29:03 所属栏目:Windows 来源:网络整理
导读:在 Windows XP上从不同的 Python版本计算时获得两个不同的修改时间. 的python2.4 C:Copy of elispc:python24pythonPython 2.4.4 (#71,Oct 18 2006,08:34:43) [MSC v.1310 32 bit (Intel)] on win32Type "help","copyright","credits" or "license" for mo
在
Windows XP上从不同的
Python版本计算时获得两个不同的修改时间.
的python2.4 C:Copy of elisp>c:python24python Python 2.4.4 (#71,Oct 18 2006,08:34:43) [MSC v.1310 32 bit (Intel)] on win32 Type "help","copyright","credits" or "license" for more information. >>> import os >>> os.path.getmtime("auto-complete-emacs-lisp.el") 1251684178 >>> ^Z python2.6的 C:Copy of elisp>C:Python26python Python 2.6.4 (r264:75708,Oct 26 2009,08:23:19) [MSC v.1500 32 bit (Intel)] on win32 Type "help","credits" or "license" for more information. >>> import os >>> os.path.getmtime("auto-complete-emacs-lisp.el") 1251687778.0 >>> Python2.6和Python2.4报告的差异为3600秒. 这种奇怪行为的原因是什么? 解决方法
这是Microsoft实施C标准库的一个错误. Python 2.4曾经使用stdlib fstat调用来获取文件信息,因此可能会在使用DST的语言环境中耗尽一小时.
在Python 2.5及更高版本中,os.stat在Windows上运行时调用直接的Win32-only API来获取文件信息,从而产生正确的输出.有关更多信息,请参见this thread (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读