Optimize code structure to improve code readability and maintainability.
This commit is contained in:
6 files changed
+18
-15
No files matched your search
@@ -36,12 +36,6 @@
|
||||
6. 显示未公布成绩的课程,即已选课但尚未出成绩的课程。
|
||||
7. 显示异常的课程,即已出成绩但用户未选课的课程。
|
||||
|
||||
## 未来的计划
|
||||
|
||||
1. 重写[详细使用方法](https://github.com/NianBroken/ZFCheckScores/blob/main/DetailedUsage.md "详细使用方法")。
|
||||
2. 增加显示学分,如 当前学分:54 / 280。
|
||||
3. 代码重构。
|
||||
|
||||
## 使用方法
|
||||
|
||||
### 1. [Fork](https://github.com/NianBroken/ZFCheckScores/fork "Fork") 本仓库
|
||||
|
||||
+5
-2
@@ -1,8 +1,10 @@
|
||||
def get_grade(student_client, output_type="none"):
|
||||
# 获取成绩信息
|
||||
grade_data = student_client.get_grade("").get("data", {})
|
||||
grade_data = student_client.get_grade().get("data", {})
|
||||
grade = grade_data.get("courses", [])
|
||||
|
||||
# 成绩不为空时
|
||||
if grade:
|
||||
# 遍历 grade 中的每个字典,将 title 中的中文括号替换为英文括号
|
||||
for course_data_grade in grade:
|
||||
course_data_grade["title"] = (
|
||||
@@ -20,7 +22,8 @@ def get_grade(student_client, output_type="none"):
|
||||
|
||||
# (百分制成绩*学分)的总和
|
||||
sum_of_percentage_grades_multiplied_by_credits = sum(
|
||||
float(course["percentage_grades"]) * float(course["credit"]) for course in grade
|
||||
float(course["percentage_grades"]) * float(course["credit"])
|
||||
for course in grade
|
||||
)
|
||||
|
||||
# GPA计算 (学分*绩点)的总和/学分总和
|
||||
|
||||
+4
-2
@@ -14,10 +14,10 @@ def get_info(student_client, output_type="none"):
|
||||
)
|
||||
|
||||
grade = get_grade(student_client, output_type="grade")
|
||||
gpa = get_grade(student_client, output_type="gpa")
|
||||
percentage_gpa = get_grade(student_client, output_type="percentage_gpa")
|
||||
|
||||
if grade:
|
||||
gpa = get_grade(student_client, output_type="gpa")
|
||||
percentage_gpa = get_grade(student_client, output_type="percentage_gpa")
|
||||
# 整合个人信息
|
||||
gpa_info = f"\n当前GPA:{gpa}\n" f"当前百分制GPA:{percentage_gpa}\n" f"------"
|
||||
integrated_info = f"{info}{gpa_info}"
|
||||
@@ -28,3 +28,5 @@ def get_info(student_client, output_type="none"):
|
||||
return integrated_info
|
||||
else:
|
||||
return "获取个人信息:参数缺失"
|
||||
else:
|
||||
return info
|
||||
Loaded 3 of 6 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user