From 28568a1792a5fee911604e8dfbfc2854d12fcc41 Mon Sep 17 00:00:00 2001 From: NY Date: Thu, 5 Jun 2025 16:58:44 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=AD=97=E7=AC=A6=E4=B8=B2=E5=B7=AE?= =?UTF-8?q?=E5=BC=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts.db | Bin 32768 -> 32768 bytes scripts/比较两个字符串的差异.py | 16 ++++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts.db b/scripts.db index ccd42b8cc8050b792c531462a961e8f6dcab3b98..4647c5f4d47ca2f9d712135044be51245751bac6 100644 GIT binary patch delta 42 ycmZo@U}|V!njp;>GEv5vF=S)Ho*G7;&9b$5jEtO<73SJ5k1&(RX9Qo*G7u&9b$5jEwA)73 list: matched = True break if not matched: - missing_in_1.append(f"{val:.6f} (位置 {idx})") + missing_in_1.append((idx, f"{val:.6f} (位置 {idx})")) for val, idx in nums1: matched = False for v2 in set2: @@ -61,35 +61,35 @@ def process(input_strings: list) -> list: matched = True break if not matched: - missing_in_2.append(f"{val:.6f} (位置 {idx})") + missing_in_2.append((idx, f"{val:.6f} (位置 {idx})")) else: set1 = {n[0] for n in nums1} set2 = {n[0] for n in nums2} for val, idx in nums2: if val not in set1: - missing_in_1.append(f"{val:.6f} (位置 {idx})") + missing_in_1.append((idx, f"{val:.6f} (位置 {idx})")) for val, idx in nums1: if val not in set2: - missing_in_2.append(f"{val:.6f} (位置 {idx})") + missing_in_2.append((idx, f"{val:.6f} (位置 {idx})")) except ValueError: return ["错误:输入包含无法转换为数值的元素"] else: set1, set2 = set(elements1), set(elements2) for i, e in enumerate(elements2, 1): if e not in set1: - missing_in_1.append(f"{e} (位置 {i})") + missing_in_1.append((i, f"{e} (位置 {i})")) for i, e in enumerate(elements1, 1): if e not in set2: - missing_in_2.append(f"{e} (位置 {i})") + missing_in_2.append((i, f"{e} (位置 {i})")) if missing_in_1: result.append("字符串1相对于字符串2缺少:") - result.extend(sorted(missing_in_1)) + result.extend(item[1] for item in sorted(missing_in_1, key=lambda x: x[0])) else: result.append("字符串1相对于字符串2没少") if missing_in_2: result.append("字符串2相对于字符串1缺少:") - result.extend(sorted(missing_in_2)) + result.extend(item[1] for item in sorted(missing_in_2, key=lambda x: x[0])) else: result.append("字符串2相对于字符串1没少")