如何在 Python 類中使用列舉?
python 有一個名為“enum”的模組,其作用是幫助 pyhon 使用列舉。
#import enum
import enum
# use enum in class
class Car(enum.Enum):
suzuki = 1
Hyundai = 2
Dezire = 3
print ("All the enum values are : ")
for c in (Car):
print(c)
廣告
python 有一個名為“enum”的模組,其作用是幫助 pyhon 使用列舉。
#import enum
import enum
# use enum in class
class Car(enum.Enum):
suzuki = 1
Hyundai = 2
Dezire = 3
print ("All the enum values are : ")
for c in (Car):
print(c)