perf:utils.tools.list_dict_find 功能优化

This commit is contained in:
ktianc 2023-06-19 15:39:52 +08:00
parent 56fda7d2be
commit 072e759f67

View File

@ -40,10 +40,7 @@ def list_dict_find(options: List[dict], key: str, value: any) -> Union[dict, Non
"""
字典列表查找
"""
for item in options:
if item.get(key) == value:
return item
return None
return next((item for item in options if item.get(key) == value), None)
def get_time_interval(start_time: str, end_time: str, interval: int, time_format: str = "%H:%M:%S") -> List: