看板 Python 關於我們 聯絡資訊
※ 引述《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
s82237823: 謝謝 04/20 08:29