Discuss / Python / 加油吧~~

加油吧~~

Topic source

class Student(object):

    def __init__(self, name, gender):

        self.name = name

        self.__gender = gender

    def get_gender(self):

        return self.__gender

    def set_gender(self,gender):

        if 0<=gender<=100:

            self.__gender=gender

        else:

            raise ValueError('数值范围0-100')

一盒噪噪

#2 Created at ... [Delete] [Delete and Lock User]

gender是字符串,并不是int或者float

if条件错了


  • 1

Reply