Skip to content

Commit e2c3e4e

Browse files
committed
By Zhao Kun Peng
1 parent f8dbf81 commit e2c3e4e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

装饰器/05.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Foo(object):
2+
def __init__(self, var):
3+
self._var = var
4+
5+
@property
6+
def var(self):
7+
return self._var
8+
@var.setter
9+
def var(self,var):
10+
self._var =var
11+
12+
foo =Foo("var_1")
13+
print(foo.var)
14+
foo.var = "var_2"
15+
print(foo.var)

0 commit comments

Comments
 (0)