尝试使用“.strTime”拆分字典中的时间戳值
所以我有一组值,这些值是从.CSV文件导入字典的。它们的格式为hh:mm:ss,但不是使用“.strtime”函数的正确数据类型。 最终的结果是将字典中的每个时间戳转换为秒,但是我似乎无法使“.strptime”正常工作,因为值的数据类型不对。 “.strtime”函数是否正确使用?你知道吗
迄今为止的准则:
from datetime import time
InTime=open("CameraIn.csv", 'rt')
OutTime=open("CameraOut.csv",'rt')
SpeedLimit = int(input("what is the speed limit? "))
#SpeedLimit = SpeedLimit*2.23694
line = InTime.readline()
InTimeByReg={}
OutTimeByReg={}
#def Speeding_Test(key):
#MetresInSeconds = int(OutTimeByReg(key)) - int(InTimeByReg(key))
#if MetresInSeconds > 26:
# SpeedingCars = open("SpeedingCars.txt", "a")
# SpeedingCars.write(str(key))
for line in InTime:
(reg,time)= line.split(",")
InTimeByReg[reg]=time.strip()
for line in OutTime:
(reg,time)= line.split(",")
OutTimeByReg[reg]=time.strip()
#for key in InTimeByReg:
# Speeding_Test(key)
我导入的文件如下:
你知道吗(卡梅林.csv): BD51 SMR,00:01:24 AV51 CDR,02:24:02 飞行计划05 KLR,05:48:17 AH09 DPU,10:12:56 KL03日刊,16:43:59
你知道吗(摄像机输出.csv): BD51 SMR,00:02:00 AV51播音员,02:24:42 飞行计划05 KLR,05:48:58 AH09 DPU,10:13:20 KL03 ZRC,16:44:14
目前没有回答
相关问题 更多 >
编程相关推荐