From 0eca7a5328a120784053a13ab2fa4ca677ae4718 Mon Sep 17 00:00:00 2001 From: Feichuan <72015001+ifeichuan@users.noreply.github.com> Date: Wed, 22 Jan 2025 20:02:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=9C=A8=E6=88=90?= =?UTF-8?q?=E7=BB=A9=E5=B8=A6=E5=B0=8F=E6=95=B0=E7=82=B9=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=E7=A8=8B=E5=BA=8F=E5=87=BA=E9=94=99=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#29)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update get_grade.py fix float str bug * Update from GitHub Actions * Update from GitHub Actions * Update from GitHub Actions * Update from GitHub Actions * Update from GitHub Actions * Update from GitHub Actions * Update from GitHub Actions * Update from GitHub Actions * Update from GitHub Actions * Update from GitHub Actions * Update from GitHub Actions * Update from GitHub Actions * Update from GitHub Actions * Update from GitHub Actions * Update from GitHub Actions * Update from GitHub Actions * Update from GitHub Actions * Update from GitHub Actions * Update from GitHub Actions * Update from GitHub Actions * Update from GitHub Actions * 修复成绩小数点错误 --------- Co-authored-by: GitHub Actions Co-authored-by: 碎念_Nian --- data/info.txt | 2 +- scripts/get_grade.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/data/info.txt b/data/info.txt index 691b3c9..65fdc03 100644 --- a/data/info.txt +++ b/data/info.txt @@ -1 +1 @@ -09975406912bb31cacc59f2573b68768 \ No newline at end of file +6f08e8e384ed9de53775b4b1a7f1ebd6 \ No newline at end of file diff --git a/scripts/get_grade.py b/scripts/get_grade.py index 8c99540..2fe36a9 100644 --- a/scripts/get_grade.py +++ b/scripts/get_grade.py @@ -28,7 +28,7 @@ def get_grade(student_client, output_type="none"): # 成绩不为空时 if grade: # 过滤出成绩大于等于60分的课程 - filtered_grade = list(filter(lambda x: int(x["percentage_grades"]) >= 60, grade)) + filtered_grade = list(filter(lambda x: float(x["percentage_grades"]) >= 60, grade)) # 遍历 grade 中的每个字典,将 title 中的中文括号替换为英文括号 for course_data_grade in grade: @@ -79,9 +79,10 @@ def get_grade(student_client, output_type="none"): for _, course in enumerate(sorted_grade[:8]): # 如果成绩非数字,如及格、良好、中等、优秀等,则显示百分制成绩 - if str(course["grade"]).isdigit(): + try: + float(course["grade"]) # 检查成绩是否为数字 score_grades = course["grade"] - else: + except ValueError: score_grades = f"{course['grade']} ({course['percentage_grades']})" # 整合成绩信息