The first is to learn @property's notes.
#!/usr/bin/env python#-*-coding:utf-8-*-#@Time: 2017/5/14 22:18#@Author: 15407_000#@Site:#@File: Using @property.py#@Software: PycharmclassStudent (object): Score=10defGetscore (self):returnSelf.scoredefSetScore (self,value):if notisinstance (value,int):RaiseValueError ("score must be int") ifValue <0orvalue>100: RaiseValueError ("score must be 0~100") Self.score=valuePass Passs=student () S.setscore (60)Print(S.getscore ()) S.setscore (1111)
Then there is the study of multiple inheritance:
#!/usr/bin/env python#-*-coding:utf-8-*-#@Time: 2017/6/6 21:50#@Author: 15407_000#@Site:#@File: Multiple inheritance. py#@Software: PycharmclassA (object):defRun (self):Print("A runs")classB (object):defRun (self):Print("B runs")classC (b,a):#here Class C inherits A, and B is inherited, but the run method of Class B is called. " "#但是如果是这样继承的: Class C (A, b): Pass then when you call run, you use A's Run method instead of the" " Passx=C () x.run ()
A few of the learning notes in the Liaoche teacher's python tutorial