热线电话:13121318867

登录
2018-11-28 阅读量: 685
在 Python 中使用枚举量

我们可以用如下方法来创建枚举定义:

class Shapes:
Circle, Square, Triangle, Quadrangle = range(4)

print(Shapes.Circle)
print(Shapes.Square)
print(Shapes.Triangle)
print(Shapes.Quadrangle)

#1-> 0
#2-> 1
#3-> 2
#4-> 3
0.0000
2
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子