From 499baf51fb932d444a86174354fe6ee53677bbe8 Mon Sep 17 00:00:00 2001 From: lededev Date: Thu, 14 Apr 2022 01:21:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ADC_function.py | 9 ++------- config.py | 12 +++--------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/ADC_function.py b/ADC_function.py index bcda6c9..8165019 100644 --- a/ADC_function.py +++ b/ADC_function.py @@ -578,11 +578,6 @@ def delete_all_elements_in_str(string_delete: str, string: str): return string +# print format空格填充对齐内容包含中文时的空格计算 def cnspace(v: str, n: int) -> int: - """ - print format空格填充对齐内容包含中文时的空格计算 - """ - cw = 0 - for c in v: - cw += 1 if category(c) in ('Lo',) else 0 - return n - cw + return n - [category(c) for c in v].count('Lo') diff --git a/config.py b/config.py index 4dc0a9f..4cd17a8 100644 --- a/config.py +++ b/config.py @@ -181,15 +181,9 @@ class Config: if value.isnumeric() and int(value) >= 0: return int(value) sec = 0 - sv = re.findall(r'(\d+)s', value, re.I) - mv = re.findall(r'(\d+)m', value, re.I) - hv = re.findall(r'(\d+)h', value, re.I) - for v in sv: - sec += int(v) - for v in mv: - sec += int(v) * 60 - for v in hv: - sec += int(v) * 3600 + sec += sum(int(v) for v in re.findall(r'(\d+)s', value, re.I)) + sec += sum(int(v) for v in re.findall(r'(\d+)m', value, re.I)) * 60 + sec += sum(int(v) for v in re.findall(r'(\d+)h', value, re.I)) * 3600 return sec def is_translate(self) -> bool: