Skip to content

Commit fce9442

Browse files
committed
By Zhao Kun Peng
0 parents  commit fce9442

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

oop/01.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# 定义一个空的类
2+
class student():
3+
pass
4+
#定义一个对象
5+
mingyue=student()
6+
7+
class PythonStudent():
8+
9+
name=None
10+
age=18
11+
course="Python"
12+
13+
14+
def doHomework(self):
15+
print('I 在做作业')
16+
17+
#推荐在函数末尾使用return语句
18+
return None
19+
20+
#实例化一个叫yueyue的学生,是一个具体的人
21+
yueyue=PythonStudent()
22+
print(yueyue.name)
23+
print(yueyue.age)
24+
#注意成员函数的调用
25+
yueyue.doHomework()

0 commit comments

Comments
 (0)