class Percentage(float): """表示百分比的类,转换字符串时自动乘以100并添加百分号""" def __str__(self): return f"{self * 100:.2f}%"