实验5
作者:互联网
class StudentDoc:
def __init__(self, number, name, subject, python):
self.number = number
self.name = name
self.subject = subject
self.python = python
def info(self):
print('Number:', str(self.number), 'Name:', self.name, 'Subject:', self.subject, 'Sorce:', str(self.python))
def sorce(self):
return self.python
def change_python(self,x):
self.python = x
def main():
u1 = StudentDoc(1, 'aaa', 'abc', 101)
u2 = StudentDoc(2, 'bbb', 'def', 102)
u1.info()
print(u1.sorce())
u2.info()
print(u2.sorce())
if __name__ == '__main__':
main()
import student
s1 = student.StudentDoc(110, 'ababab', 'chinese', 9)
s2 = student.StudentDoc(119, 'bababa', 'python', 10)
s1.info()
s2.info()
s1.change_python(99)
s2.change_python(100)
s1.info()
s2.info()
标签:info,__,name,python,self,实验,StudentDoc 来源: https://www.cnblogs.com/zcc-mxy/p/14809727.html