From 93d2047c7ac905bfb4c9c30de5543ec6591ba491 Mon Sep 17 00:00:00 2001 From: "Formatter [BOT]" Date: Wed, 27 Nov 2024 10:31:40 +0000 Subject: [PATCH] =?UTF-8?q?Auto-format=20code=20=F0=9F=A7=B9=F0=9F=8C=9F?= =?UTF-8?q?=F0=9F=A4=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaomusic/utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xiaomusic/utils.py b/xiaomusic/utils.py index da9fb75..c50dd4a 100644 --- a/xiaomusic/utils.py +++ b/xiaomusic/utils.py @@ -527,9 +527,9 @@ def chinese_to_number(chinese): unit = 1 num = 0 # 处理特殊情况:以"十"开头时,在前面加"一" - if chinese.startswith('十'): - chinese = '一' + chinese - + if chinese.startswith("十"): + chinese = "一" + chinese + # 如果只有一个字符且是单位,直接返回其值 if len(chinese) == 1 and chinese_to_arabic[chinese] >= 10: return chinese_to_arabic[chinese] @@ -544,7 +544,7 @@ def chinese_to_number(chinese): else: num += val * unit result += num - + return result