0
我從字典中提取timetamp,然後將其轉換爲時間格式。 當我嘗試使用時間delta它得到誤差datetime.datetime.now()
比較:Timedelta不受支持的days組件| python 2.7
dict={'Username': 'abc', 'Timestamp': '5/17/2017 16:52:35', 'GroupName': 'Cpositive'}
dictime=dict["Timestamp"]
dictime = datetime.datetime.strptime(dictime, '%m/%d/%Y %H:%M:%S')
print(dictime)
finaltime=(datetime.datetime.now() - datetime.timedelta(dictime))
print(finaltime)
輸出:
TypeError: unsupported type for timedelta days component: datetime.datetime
'datetime.timedelta(dictime)'沒有意義,你不能使用datetime作爲timedelta的參數 – mata