将两组日期相互比较,看看一组是否在另一组中

Compare two sets of dates to each other to see if one is found inside the other

我有两组日期(总共 4 个日期),我们称它们为 A 组和 B 组。我需要查看是否在 A 组中以任何顺序找到 B 组日期范围。下面是如何将找到日期:

组A:

Start          Stop
11/9/2017      11/10/2017  
11/16/2017     11/18/2017

组B

Start          Stop
11/7/2017      11/11/2017   # should match the first one in set A
11/15/2017     11/16/2017   # Should match the second one in set A

我认为一组 < > 可以工作,但我似乎无法得到它来匹配我正在寻找的东西。

我尝试了以下方法:

start1 = datetime(2017,11,9)
stop2 = datetime(2017,11,10)
start2 = datetime(2017,11,7)
stop2 = datetime(2017,11,11)

start1 >= start2 or stop1 <= stop2

结果为真。但我觉得我可能会因为在其中放置 or 而遗漏一些内容。

比较Python 3:

中日期的一个非常基本的例子
set_a_start = datetime.datetime(2017, 1, 1)
set_a_end = datetime.datetime(2017, 12, 31)

set_b_start = datetime.datetime(2017, 4, 1)
set_b_end = datetime.datetime(2017, 4, 30)

if(set_a_start <= set_b_start and set_a_end >= set_b_end):
    print("Set B is within Set A")

更新:添加“<=”表示两个集合共享相同的开始日期(“>=”表示结束日期)