本帖最后由 ivor 于 2020-5-23 13:16 编辑
- #! /usr/bin/env python3
- # coding:utf-8
-
- import re
- from datetime import datetime
-
- tList = re.findall(r"\d+:\d+.\d+", "[0:00.00,15:40.65,24:27.45,28:26.23]")
- a = map(lambda x,x1: re.sub("0{4}$|^0:", "", str(datetime.strptime(x1, "%M:%S.%f") - datetime.strptime(x, "%M:%S.%f"))), tList,tList[1::])
- print(list(a))
复制代码 结果和你的有点不一样
['15:40.65', '08:46.80', '03:58.78'] |