From 6e01cd03d19b8f3d9a182d96fa985b7f109bc82b Mon Sep 17 00:00:00 2001 From: "firedcto@gmail.com" Date: Tue, 16 Jul 2024 16:52:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=BC=AB=E5=B7=A1=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E4=BC=9A=E5=8D=A1=E4=BD=8F=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- task/NewManXunTask.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/task/NewManXunTask.py b/task/NewManXunTask.py index ccf0691..b86e88e 100644 --- a/task/NewManXunTask.py +++ b/task/NewManXunTask.py @@ -641,8 +641,12 @@ def target_index_array(lst): def remove_non_digits_and_convert(s): # Use regular expression to keep only digits and '+' characters clean_string = re.sub(r'[^0-9+]', '', s) + clean_string = clean_string.strip('+') # Evaluate the cleaned string as a mathematical expression - return eval(clean_string) + try: + return eval(clean_string) + except Exception as e: + return 0 gray_percent_per_line = 0.03660270078 * 100