import Permissionclass User(): def can(self,permission): return self.permission & permission === permission#位与操作符 &,对比两个数据,位值相同的位为1 user.can(Permission.Administer)