Python enum multiple values 枚举多个值

Python enum multiple values 枚举多个值


转载自:https://tutorial.eyehunts.com/python/python-enum-multiple-values-example-code/

Use MultiValueEnum to get enum multiple values in Python. You have to install and import aenum library and this is the easiest way.

# Python enum with multiple values example
from aenum import MultiValueEnum


class DType(MultiValueEnum):
    float32 = "f", 8
    double64 = "d", 9


print(DType("f"))
print(DType(9))

猜你喜欢

转载自blog.csdn.net/LIWEI940638093/article/details/123528657
今日推荐