Skip to content

Commit e15dd0a

Browse files
committed
1.测试python 面向对象
1 parent 2fc0ee2 commit e15dd0a

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

com/lxl/test/Sln_Demo.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,40 @@
11
import keyword as kw
22

3-
print(kw.kwlist)
4-
#
3+
# print(kw.kwlist)
4+
5+
6+
class Person:
7+
8+
name = ''
9+
age = ''
10+
11+
def __init__(self):
12+
self.name='张三'
13+
self.age='10'
14+
15+
def __init__ (self,nameParam,ageParam):
16+
self.name=nameParam
17+
self.age=ageParam
18+
19+
def speak(self):
20+
return "姓名是:"+self.name+";"+"年龄是:"+self.age
21+
22+
23+
if __name__ == '__main__':
24+
25+
# p1 = Person()
26+
# p1.age='18'
27+
# p1.name='bruce'
28+
# print(p1.speak())
29+
p2 = Person('李四','20')
30+
print(p2.speak())
31+
32+
33+
34+
35+
36+
37+
38+
539

640

0 commit comments

Comments
 (0)