工作日的努力python_python计算上班时间的问题

展开全部import datetimeimport codecsdef read_time(str_x,str_s):a=str_x.split('    ')

展开全部

import datetime

import codecs

def read_time(str_x,str_s):

a=str_x.split('    ')

date_x=datetime.datetime.strptime(a[1],'%Y-%m-%d %H:%M:%S')

a=str_s.split('    ')

date_s=datetime.datetime.strptime(a[1],'%Y-%m-%d %H:%M:%S')

d=date_x - date_s

shangb_d = a[1].split(' ')

return a[0]+'  '+str(d.total_seconds())+'  '+a[2].strip()+ '  '+shangb_d[0]

fp=codecs.open('zhidao_1.txt','r','utf-8')

f_w=codecs.open('results.txt','w','utf-8')

for line_xiab in codecs.open('zhidao_2.txt','r','utf-8'):

line_shangb = fp.readline()

a = read_time(line_xiab,line_shangb)

f_w.write(a+'\n')

fp.close()

f_w.close()

没人回答我就回答一个吧,其e5a48de588b662616964757a686964616f31333337383933实还是学学基础比较好,可以看看云课堂上的用Python做些事,上面变量章节对日期变量和文件变量讲解可以满足你的需求。