getmtime在Py2.5和Py2.4之间有所不同 [英] getmtime differs between Py2.5 and Py2.4
问题描述
我只在Windows上试过这个:
在Python 2.4中os.path.getmtime返回当地时间,
在Python 2.5中它似乎返回GMT:
import os,time
print ctime.time(os.path.getmtime(foo))
在时区上与Python 2.4和Python 2.5不同。
现在,两个stat调用的实现在Windows上有所不同
两个版本之间。
我实际上更喜欢新的行为,因为我相信
报告文件的时间不应该依赖于时区或其他
本地设置,但旧的行为也是Windows
显示的时间 - 并且存在不兼容性。
这是一个错误吗?
- Josef
I tried this on Windows only:
In Python 2.4 os.path.getmtime returned the local time,
in Python 2.5 it seems to return GMT:
import os, time
print ctime.time(os.path.getmtime(foo))
differs on Python 2.4 and Python 2.5 by the timezone.
Now, the implementation of the two stat calls differs on Windows
between the two versions.
I actually like the new behaviour better, because I believe the
reported time of a file should not depend on the timezone or other
local settings, however the old behaviour is the time also Windows
shows - and there is an incompatibility.
Is this a bug?
- Josef
推荐答案
这是一个错误吗?
为什么你没看过之前发布的回复? John Machin
回复(< 11 ********************** @ l77g2000hsb.googlegroups .com>)
你错了:Py2.5和Py2.4之间的结果
of os.path.getmtime没有区别。它总是返回
UTC,并且永远都会。
问候,
马丁
Is this a bug?
Why don''t you read the responses posted earlier? John Machin
replied (in <11**********************@l77g2000hsb.googlegroups .com>)
that you are mistaken: There is NO difference between the outcome
of os.path.getmtime between Py2.5 and Py2.4. It always did return
UTC, and always will.
Regards,
Martin
Martin v.L?wis写道:
Martin v. L?wis wrote:
>这是一个错误吗?
>Is this a bug?
为什么你不读早先发布的回复? John Machin
回复(< 11 ********************** @ l77g2000hsb.googlegroups .com>)
你错了:Py2.5和Py2.4之间的结果
of os.path.getmtime没有区别。它总是返回
UTC,并且永远都会。
问候,
Martin
Why don''t you read the responses posted earlier? John Machin
replied (in <11**********************@l77g2000hsb.googlegroups .com>)
that you are mistaken: There is NO difference between the outcome
of os.path.getmtime between Py2.5 and Py2.4. It always did return
UTC, and always will.
Regards,
Martin
Err .....:
[E:\Projects] dir * .py
卷在驱动器E是数据序列号是2C4F:9C2D
目录E:\Projects \ * .py
31-03-2007 20: 46 511 log.py
25-11-2006 16:59 390 p64.py
7-03-2007 23:07 207 sock.py
3-02-2007 16:15 436 threads.py
4个文件中的1.544个字节和0个目录分配的16.384个字节
287.555.584个字节免费>
[E:\Projects] c:\Python24 \ python.exe -c" import os; print os.path.getmtime(''p64.py'')"
1164470381
[E:\Projects] c:\ Pepy25 \ python.exe -c" import os; print os.path.getmtime(''p64.py'')"
1164466781.28
这是Windows XP上的python 2.4.4和Python 2.5.1。 br />
报告的时间明显不同。
- Irmen
Err.....:
[E:\Projects]dir *.py
Volume in drive E is Data Serial number is 2C4F:9C2D
Directory of E:\Projects\*.py
31-03-2007 20:46 511 log.py
25-11-2006 16:59 390 p64.py
7-03-2007 23:07 207 sock.py
3-02-2007 16:15 436 threads.py
1.544 bytes in 4 files and 0 dirs 16.384 bytes allocated
287.555.584 bytes free
[E:\Projects]c:\Python24\python.exe -c "import os; print os.path.getmtime(''p64.py'')"
1164470381
[E:\Projects]c:\Python25\python.exe -c "import os; print os.path.getmtime(''p64.py'')"
1164466781.28
This is python 2.4.4 and Python 2.5.1 on windows XP.
The reported time clearly differs.
--Irmen
5月8日,3:26 am,Josef Dalcolmo< dalco ... @ vh-s.dewrote:
On May 8, 3:26 am, Josef Dalcolmo <dalco...@vh-s.dewrote:
我在Windows上试过这个:
在Python 2.4中os.path.getmtime返回当地时间,在Python 2.5中返回
似乎返回GMT:
import os,time
print ctime.time(os.path.getmtime(foo))
I tried this on Windows only:
In Python 2.4 os.path.getmtime returned the local time,
in Python 2.5 it seems to return GMT:
import os, time
print ctime.time(os.path.getmtime(foo))
我认为你的意思是time.ctime :-)
I think you mean time.ctime :-)
>
在时区上与Python 2.4和Python 2.5不同。
>
differs on Python 2.4 and Python 2.5 by the timezone.
您没有提供任何证据。您是否阅读了我之前的
帖子的回复?
You have presented no evidence. Did you read my reply to your previous
post?
这是一个错误吗?
Is this a bug?
这是一个什么错误?
我的时区距离UTC只有* TEN *小时。这就是我得到的[Windows
XP专业版SP2]:
C:\ junk> dir newfile.txt
驱动器C中的卷没有标签。
卷序列号为7D12-D6D2
08/05/2007 09:17 AM 0 newfile.txt
1文件0字节
0 Dir(s)44,508,061,696字节免费
C:\ junk> for%v in(4,5)do \python2%v\python -c" import os,time,sys;
print sys
..version,time.ctime(float(os.path.getmtime(''C:\\\\\\\\\\\\ \ newfile.txt'')))"
C:\ junk> \ python24 \ python -c" import os,time,sys; print sys.version,
time.ctime
(float(os.path.getmtime(''C:\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ')))
2.4.3(#69,2006年3月29日,17:35:34)[MSC v.1310 32 bit(Intel)] Tue May
08 09:17:
12 2007
C:\ junk> \ python25 \ python -c" import os,time, SYS; print sys.version,
time.ctime
(float(os.path.getmtime(''C:\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ')))
2.5.1(r251:54863,2007年4月18日,08:51:08)[MSC v.1310 32 bit(Intel)]
星期二08月5日
09:17:12 2007
C:\ junk>
为了避免带宽浪费,我省略了类似的Python 2.1,
2.2和2.3的结果。
Is what a bug?
My timezone is *TEN* hours away from UTC. Here''s what I get [Windows
XP Pro SP2]:
C:\junk>dir newfile.txt
Volume in drive C has no label.
Volume Serial Number is 7D12-D6D2
Directory of C:\junk
08/05/2007 09:17 AM 0 newfile.txt
1 File(s) 0 bytes
0 Dir(s) 44,508,061,696 bytes free
C:\junk>for %v in (4,5) do \python2%v\python -c "import os, time, sys;
print sys
..version, time.ctime(float(os.path.getmtime(''C:\\junk\
\newfile.txt'')))"
C:\junk>\python24\python -c "import os, time, sys; print sys.version,
time.ctime
(float(os.path.getmtime(''C:\\junk\\newfile.txt''))) "
2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] Tue May
08 09:17:
12 2007
C:\junk>\python25\python -c "import os, time, sys; print sys.version,
time.ctime
(float(os.path.getmtime(''C:\\junk\\newfile.txt''))) "
2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)]
Tue May 08
09:17:12 2007
C:\junk>
To avoid bandwidth waste, I''ve omitted similar results for Python 2.1,
2.2, and 2.3.
这篇关于getmtime在Py2.5和Py2.4之间有所不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!