九州体育网 - 十年信誉网站

关于作者

Discuss / Python / Nice!

Nice!

Topic source

倚墨华

#1 Created at ...

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 gender in {"male","female"}: self.__gender = gender else: return ValueError('bad error')

阴影之_刃

#2 Created at ...

init 方法不加前后下划线也行吗?

blablahbala

#3 Created at ...

不是不加下划线,而是网页显示问题,要打出下划线,可以在下划线前面加反斜杠\ init __init__


  • 1

Reply

WARNING: You are using an old browser that does not support HTML5. Please choose a modern browser (Chrome / Microsoft Edge / Firefox / Sarafi) to get a good experience.