Home >Backend Development >Python Tutorial >Introduction to the simple method of implementing enum function in Python
This article mainly introduces the method of Python to simply implement the enum function, and briefly analyzes the related skills of Python to implement the enum function. Friends in need can refer to it
The example of this article tells the simple implementation of the enum function in Python method. Share it with everyone for your reference, the details are as follows:
class Enumerate(object): def __init__(self,names): for number,name in enumerate(names.split()): setattr(self, name, number) codes = Enumerate('FOO BAR BAZ') print codes.FOO codes.FOO = 10 print codes.FOO
For more introduction on how to simply implement the enum function in Python and related articles, please pay attention to the PHP Chinese website!