import pandas as pd # 标记 - 不及格 def low_score_read(s): if s < 60: color = "red" else: color = "black" return f"color:{color}" # 标记 - 最高分 def highest_score_green(col): return ['background-color:lime' if v==col.max() else 'background-color:white' for v in col] students = pd.read_excel("C:/Users/18124/Desktop/pandas/025_条件格式化/Students.xlsx", engine="openpyxl") students.style.applymap(low_score_read, subset=['Test_1', 'Test_2', 'Test_3']) .apply(highest_score_green, subset=['Test_1', 'Test_2', 'Test_3'])