3
在最近的一个问题(Gathering numerical data from a string input)我想知道这是否是一个可以接受的答案。我认为这会提出更好的问题。这种表现形式是否可以作为一个不变的集合?还是滥用枚举?是否有任何意想不到的后果将相同的值分配给Python中枚举的不同属性?枚举具有多个属性作为收集常量
from enum import Enum
class CreditRating(Enum):
AAA = 0.01
A = 0.1
B = 0.1
creditRate = input("Please enter credit rating:")
print(CreditRating[creditRate].value)