如何从包含时间的数据集中找到导入的时间差

时间:2019-02-17 13:33:57

标签: python python-2.7

我想减去我从tt.txt文件导入的两个时间实例。但是strptime的参数必须为string(格式为'%H.%M')。我该如何解决这个问题?

我的代码:

import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime
data = np.genfromtext('tt.txt', delimiter= ' ')
sn = data[ :, ][ :,0]
dt = data[ :, ][ :,1]  # dt = depature time, 2nd column of table
at = data[ :, ][ :,2]  # at = arrival time, 3rd column of table
str1 = dt[3]
str2 = at[3]
start = datetime.strptime(str1, '%H.%M')
end = datetime.strptime(str2, '%H.%M')
c = end - start
print(c) 

0 个答案:

没有答案