From 072e759f67a51ba3d688301e7eb9bd5fb051b244 Mon Sep 17 00:00:00 2001 From: ktianc Date: Mon, 19 Jun 2023 15:39:52 +0800 Subject: [PATCH] =?UTF-8?q?perf=EF=BC=9Autils.tools.list=5Fdict=5Ffind=20?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kinit-api/utils/tools.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/kinit-api/utils/tools.py b/kinit-api/utils/tools.py index 52889ca..e38f4e2 100644 --- a/kinit-api/utils/tools.py +++ b/kinit-api/utils/tools.py @@ -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: