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

看板Python作者 (LawTea)時間5年前 (2019/04/17 16:59), 編輯推噓1(100)
留言1則, 1人參與, 5年前最新討論串2/4 (看更多)
※ 引述《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) 中間有一大段我其實看不懂你想幹嘛, 先這樣有不懂再問吧 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.227.45.150 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1555491541.A.F9C.html

04/20 08:29, 5年前 , 1F
謝謝
04/20 08:29, 1F
文章代碼(AID): #1SjkhL-S (Python)
文章代碼(AID): #1SjkhL-S (Python)