2017-03-05 99 views

回答

1

數學的簡單一點:

int(timestamp//60 * 60) 

//複製的Python 2.x的部門(/)其結果爲整數)

0

或者,如果你不聰明,你可以使用箭頭

>>> import arrow 
>>> timestamp = arrow.get(1488728901) 
>>> timestamp 
<Arrow [2017-03-05T15:48:21+00:00]> 
>>> timestamp = timestamp.floor('minute') 
>>> timestamp.format('YYYY-MMM-DD HH:mm:ss') 
'2017-Mar-05 15:48:00' 
相關問題