【发布时间】:2022-01-23 14:23:25
【问题描述】:
我从这行代码中得到 ValueError: max() arg is an empty sequence:
result = {}
ids = [...] # may be empty
objects_from_ids = func_to_fetch_objects(delivery_ids) # returns empty list, if ids are empty, or list of objects, with corresponding ids
if objects_from_ids:
result["max_dt"] = max(d["dt"] for d in objects_from_ids) # Here comes error
谁能解释一下,为什么会发生这种情况? 我已经阅读了有关空序列案例的默认值的答案,但想了解这种情况
【问题讨论】:
标签: python python-3.x python-2.7