一个列表的元素是否包含另一个列表元素

版权声明:转载请标明出处 https://blog.csdn.net/gymaisyl/article/details/88125600
new_list = [1, 2, 3]
old_list = [3, 4, 5]
judge = [False for c in new_list if c not in old_list ]
if judge:
	# judge不是None,则表示new_list中有元素是不在old_list中的

猜你喜欢

转载自blog.csdn.net/gymaisyl/article/details/88125600