在此代码中,对于3个项目mDATE0abz为:

mUNIQUE: z | mDATE0: 2010-11-14 14:55:04.293000
mUNIQUE: b | mDATE0: 2010-11-14 14:53:34.824000
mUNIQUE: a | mDATE0: 2010-11-14 14:50:14.155000


但是当我这样做

...
utc_tuple = rep.mDATE0.utctimetuple()
...


相应的utc_tuples为:

utc_tuple: time.struct_time(tm_hour=14, tm_min=55)
utc_tuple: time.struct_time(tm_hour=14, tm_min=55)
utc_tuple: time.struct_time(tm_hour=14, tm_min=55)


换句话说,对于min=55所有项目,而mDATE0具有

z --> min=55;
b --> min=53;
a --> min=50


我究竟做错了什么?请参阅我的related question。谢谢。

最佳答案

那不是代码!请发布简短的完整示例代码以说明问题。以下是我认为您正在尝试做的事情,但是如果没有看到您的代码,任何人都无法指出您的错误。

from datetime import datetime
# build up some datetime objects.
z = datetime.strptime('2010-11-14 14:55:04.293000','%Y-%m-%d %H:%M:%S.%f')
b = datetime.strptime('2010-11-14 14:53:34.824000','%Y-%m-%d %H:%M:%S.%f')
a = datetime.strptime('2010-11-14 14:50:14.155000','%Y-%m-%d %H:%M:%S.%f')
# display them
print 'z =',z
print 'b =',b
print 'a =',a
# print the minute
print 'z min =',z.utctimetuple().tm_min
print 'b min =',b.utctimetuple().tm_min
print 'a min =',a.utctimetuple().tm_min
# print the minute an easier way
print 'z min =',z.minute
print 'b min =',b.minute
print 'a min =',a.minute


输出:

z = 2010-11-14 14:55:04.293000
b = 2010-11-14 14:53:34.824000
a = 2010-11-14 14:50:14.155000
z min = 55
b min = 53
a min = 50
z min = 55
b min = 53
a min = 50

10-05 22:10