Time Interval overlap in python

前端 未结 1 1426
庸人自扰
庸人自扰 2021-01-21 21:27

Suppose I have list of time interval like

a = [datetime.time(0,0),datetime.time(8,0)]

Now I Have lacs of intervals in list like given below.

1条回答
  •  离开以前
    2021-01-21 21:31

    Your code has errors (usage of datetime/datetime.time).

    This code will filter out from b everything, that does not overlap with a:

    b = [x for x in b if a[0] < x[1] and x[0] < a[1]]
    

    0 讨论(0)
提交回复
热议问题