09-15-周一_11-25-51

This commit is contained in:
2025-09-15 11:25:51 +08:00
parent 4a83558acd
commit 257e88d79f
5 changed files with 23 additions and 23 deletions
+7 -7
View File
@@ -169,8 +169,8 @@ class Human:
def work(self):
print(self,'会工作')
Human.work('chensong')
Human.__dict__['work']('chensong')
Human.work('张三')
Human.__dict__['work']('张三')
```
## 从对象的角度研究类
@@ -210,7 +210,7 @@ class Human:
self.a = age
self.h = hobby
obj = Human('chensong','''18','')
obj = Human('张三','''18','')
```
### 对象操作对象空间属性
@@ -229,7 +229,7 @@ class Human:
self.a = age
self.h = hobby
obj = Human('chensong','',18,'')
obj = Human('张三','',18,'')
print(obj.__dict__)
```
@@ -247,7 +247,7 @@ class Human:
self.a = age
self.h = hobby
obj = Human('chensong','',18,'')
obj = Human('张三','',18,'')
obj.job = 'IT'
del obj.n
obj.s = ''
@@ -269,7 +269,7 @@ class Human:
self.a = age
self.h = hobby
obj = Human('chensong','',18,'')
obj = Human('张三','',18,'')
print(obj.mind)
print(obj.language)
obj.a = 666
@@ -297,7 +297,7 @@ class Human:
def tools(self):
print(self.n,'会使用工具')
obj = Human('chensong','',18,'')
obj = Human('张三','',18,'')
obj.work()
obj.tools()
```