Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python摆脱默认日期1900-01-01_Python_Datetime - Fatal编程技术网

python摆脱默认日期1900-01-01

python摆脱默认日期1900-01-01,python,datetime,Python,Datetime,我想知道我是否可以在输出中去掉1900-01-01而不改变太多代码。我知道有一种方法可以解决这个问题,但我不明白如何在不改变所有内容的情况下将这些行应用到我的代码中。如果我能得到一些礼物,我会非常感激的 import csv from datetime import datetime time_difference= open('Book1.csv')#it is important that within the csv file that the times do not have extr

我想知道我是否可以在输出中去掉1900-01-01而不改变太多代码。我知道有一种方法可以解决这个问题,但我不明白如何在不改变所有内容的情况下将这些行应用到我的代码中。如果我能得到一些礼物,我会非常感激的

import csv
from datetime import datetime
time_difference= open('Book1.csv')#it is important that within the csv file that the times do not have extra spaces before, that they are foramtted to military time and that these settings are saved before code is ran
time_difference_csv=csv.reader(time_difference)

for row in time_difference_csv:
    w = [[datetime.strptime(i[0],'%H:%M:%S')]+ [datetime.strptime(i[1],'%H:%M:%S')] for i in time_difference_csv]
for row in w:
   p= (row[1]-row[0])
for row in w:
    l= (row[1]-row[0]) + row[0]

td= open('121Times3.csv')#imports csv with the list of times from one time source; e.g. just the scanner times
td_csv=csv.reader(td)
firstline = True

for row in td_csv:
    if firstline:    #skip first line
        firstline = False
        continue
# parse the line
for row in td_csv:
    k = [[datetime.time.strptime(i[0],'%H:%M:%S')] for i in td_csv]

for row in k:#adds the difference found earlier to all the times on the  csv. Converts all the scanner times to the wall times.
    print row[0] + p

查看输入文件的一部分可能会有所帮助。csv 1输入:测试1-12:41:09测试2-12:43:10 csv输入2:测试1:12:45:27