#每日一练 根据提供函数,返回两个列表中每个元素各一次

def union_by(a, b, fn):
  _a = set(map(fn, a))
  return list(set(a + [item for item in b if fn(item) not in _a]))

from math import floor

union_by([2.1], [1.2, 2.3], floor) # [2.1, 1.2]
原文地址:https://www.cnblogs.com/ai594ai/p/15660437.html