[英]What is wrong with this code to find the difference between 2 python tuples of datetime?
我有2個元組在Python中包含datetime。
Time_A = ((datetime.datetime(2014, 12, 10, 17, 3, 25),),)
Time_B = ((datetime.datetime(2014, 12, 10, 17, 5, 32),),)
我想找到這兩個變量之間的時差。 因此,我運行下面的代碼;
TimeGap = Time_B - Time_A
不幸的是,此時捕獲了異常錯誤。 錯誤是TypeError("unsupported operand type(s) for -: 'tuple' and 'tuple'",)
如何在python中找到Time_A
和Time_B
之間的Time_A
?
我正在使用python 2.7
在我看來,這就像一個包含所需信息的元組,因此您可以嘗試:
TimeGap = Time_B[0][0] - Time_A[0][0]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.