def difference_by(a, b, fn):
  _b = set(map(fn, b))
  return [item for item in a if fn(item) not in _b]
from math import floor

difference_by([2.1, 1.2], [2.3, 3.4], floor) # [1.2]
difference_by([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], lambda v : v['x']) # [ { x: 2 } ]

 

相关文章:

  • 2021-09-21
  • 2022-12-23
  • 2022-03-02
  • 2021-08-10
  • 2022-12-23
猜你喜欢
  • 2021-10-21
  • 2021-07-05
  • 2022-02-24
  • 2021-07-17
  • 2021-10-25
  • 2022-01-23
  • 2021-11-28
相关资源
相似解决方案