From e52f213540b0796d24aa1f9770562cabab790ec1 Mon Sep 17 00:00:00 2001 From: liuyebo <1515783401@qq.com> Date: Sat, 20 Jul 2024 17:28:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=87=91=E9=A2=9D=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E7=9A=84=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util/util.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/util/util.py b/util/util.py index 6921a94..4c3d645 100644 --- a/util/util.py +++ b/util/util.py @@ -135,12 +135,12 @@ def chinese_to_number(chinese): section += number * (unit[0] / 10) unit = [None, False] elif number > 0: - raise ValueError(f"Bad number '{chinese[i - 1]}{c}' at: {i}") + raise ValueError(f"{chinese} has bad number '{chinese[i - 1]}{c}' at: {i}") number = num else: unit = chinese_to_money_unit(c) if unit[0] == None: - raise ValueError(f"Unknown unit '{c}' at: {i}") + raise ValueError(f"{chinese} has unknown unit '{c}' at: {i}") if unit[1]: section = (section + number) * unit[0] result += section @@ -166,6 +166,10 @@ def chinese_money_to_number(chinese_money_amount): yi = chinese_money_amount.find("圆") ji = chinese_money_amount.find("角") fi = chinese_money_amount.find("分") + + if yi == -1 and ji == -1 and fi == -1: + raise ValueError(f"无法解析: {chinese_money_amount}") + y_str = None if yi > 0: y_str = chinese_money_amount[0:yi]