我從這行代碼中得到ValueError: max() arg is a 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
誰能解釋一下,為什么會發生這種情況?我已經閱讀了有關空序列案例的默認值的答案,但想了解這個案例
uj5u.com熱心網友回復:
在objects_from_ids可能是空的物件串列或錯誤的func_to_fetch_objects()
嘗試在 if 子句中列印值以了解里面發生了什么。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/392049.html
上一篇:尋找方塊圖的脈沖回應
