我一直在试图做一个函数,可以采取两个任何大小的列表(比如说,列表A和列表B),并看到列表B是否出现在列表中A,但是连续且以相同的顺序。如果以上情况属实,则返回True,否则返回False。蟒蛇 - 比较两个列表,看看是否发生在另一个连续
例如,
A:[9,0,**1,2,3,4,5,6,**7,8] and B:[1,2,3,4,5,6] is successful
A:[1,2,0,3,4,0,5,6,0] and B:[1,2,3,4,5,6] is unsuccessful.
A:[1,2,3,4,5,6] and B [6,5,3,2,1,4] fails because despite having the same
numbers, they aren't in the same order
我试着这样做使用嵌套循环到目前为止并感到有点困惑,去哪里
可能要看一看的https:/ /stackoverflow.com/questions/10106901/elegant-find-sub-list-in-list –
这是你所需要的: https://stackoverflow.com/questions/16579085/python-verifying-if-one-list-is-a-subset-of-the-other –