解决方法

  1. 使用numpy.setdiff1d
  2. 使用set
  3. 使用filter
import numpy as np

def test():
    src_a = [30, 12, 66, 34, 39, 78, 36, 57, 121]
    src_b = [30, 5, 7, 11]
    print(list(set(src_a) - set(src_b)))   # [66, 34, 36, 39, 12, 78, 121, 57]
    print(np.setdiff1d(src_a, src_b).tolist())   # [12, 34, 36, 39, 57, 66, 78, 121]
    print(list(filter(lambda x: x not in src_b, src_a)))   # [12, 66, 34, 39, 78, 36, 57, 121]

Q.E.D.


Nothing really matters to me!