Re: [問題] numpy array 一次選取兩行

作者: thefattiger (LT)   2019-04-17 16:58:59
※ 引述《s82237823 ()》之銘言:
兩行兩行的讀取, 可以用listcomp自己做
要取上下班時間差可以這樣做
import datetime
PT_record = [['AAA', '2019/03/08', 2, '17:54:43', '上班'],
['AAA', '2019/03/08', 2, '23:02:54', '下班'],
['AAA', '2019/03/13', 2, '17:45:20', '上班'],
['AAA', '2019/03/13', 2, '22:11:00', '下班']]
PT_record_zip = ((PT_record[i],PT_record[i+1]) for i in range(0,len(PT_record),2))
result = []
for on,off in PT_record_zip:
on_time = datetime.datetime.strptime(on[3],"%H:%M:%S")
off_time = datetime.datetime.strptime(off[3],"%H:%M:%S")
diff = off_time - on_time
result.append(diff)
print(result)
中間有一大段我其實看不懂你想幹嘛, 先這樣有不懂再問吧
作者: s82237823   2019-04-20 08:29:00
謝謝

Links booklink

Contact Us: admin [ a t ] ucptt.com