0

我正在尝试使用 TrialHandler.addData() 方法在我的代码中添加时间戳。但是,底层数组的精度使得无法获得我需要的确切值。

print(core.getAbsTime())    
hand.addData('time', core.getAbsTime())
print(hand.data['time'])
#prints 1410454966
#       [[1410454912.0] ...

有没有办法改变底层类型以达到所需的精度?

4

1 回答 1

2

您可能不想使用core.getAbsTime()which 返回 unix 时间戳。这并不意味着实验中的时间安排。对于实验中的事件时间,请使用

myClock = core.Clock()
myClock.reset()  # start timing
# do something here
elapsedTime = myClock.getTime()  # yay

...它以微秒为单位返回时间。查看Psychopy.corecore.Clock文档和Coder 演示中的文档和文档core.getAbsTime()

如果您想要绝对时间(年、小时、分钟等),请查看时间python 模块或在 Google 中搜索类似的模块和方法。

于 2014-09-11T17:56:20.650 回答