我試圖將一個timedelta
對象與另一個計算服務器正常運行時間:的Python 2.6.5:除以timedelta與timedelta
>>> import datetime
>>> installation_date=datetime.datetime(2010,8,01)
>>> down_time=datetime.timedelta(seconds=1400)
>>> server_life_period=datetime.datetime.now()-installation_date
>>> down_time_percentage=down_time/server_life_period
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for /: 'datetime.timedelta'
and 'datetime.timedelta'
我知道這has been solved in Python 3.2,但有來處理它的便捷方法在以前的Python版本中,除了計算微秒,秒和天的數量和分割?
感謝,
亞當
可能的重複[如何在python的datetime.timedelta上執行divison?](http://stackoverflow.com/questions/865618/how-can-i-perform-divison-on-a-datetime- timedelta-in-python) – 2012-09-13 14:37:58