将时间(例如 1:00、3:45)转换为 int/float 的简单方法?

Easy way to convert a time (ex. 1:00, 3:45) to a int/float?

将字符串(如 1:00、3:45)转换为浮点数的最佳方法?我打算使用此(见下文)代码来计算跑步者 2 英里和 3 英里的时间,但我需要先将字符串转换为 int 或 float 才能在这些计算中使用它。

twoMileTimes=[]
threeMileTimes=[]
for i in range(len(runnerNames)):
    twoMileTimes.append(round(twoMileMark[i]-oneMileMark[i],2))
    threeMileTime = fiveKMark[i]*(3/3.1)
    threeMileTime -= twoMileMark[i]
    threeMileTimes.append(round(threeMileTime,2))
>>> s = "3:45"
>>> a, b = map(int, s.split(":"))
>>> a
3
>>> b
45
>>> b = b / 60
>>> b
0.75
>>> res = round(a + b, 2)
>>> res
3.75
>>>