Python字符串比较最小/最大str
内置filter函数视为None始终返回的“函数” True。from functors import partialfrom operators import lt, gtdef filter_dates(x, lower_bound=None, upper_bound=None):lb = None if lower_bound is None else partial(lt, lower_bound)
ub = None if upper_bound is None else partial(gt, upper_bound)
return filter(lb, filter(ub, x)) (请注意,这将适用于字符串或date对象;只需传递相应类型的下限和上限。)
赞1
踩0