Class Sample def foo
This commit is contained in:
parent
30af94a979
commit
3cd256fc5f
14
python-temel/class.sample.foo.py
Normal file
14
python-temel/class.sample.foo.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
class Sample:
|
||||
def __init__(self, a, b):
|
||||
self.a = a
|
||||
self.b = b
|
||||
|
||||
def foo(k):
|
||||
print(k.a, k.b) # 10 20
|
||||
k.a = 100
|
||||
k.b = 200
|
||||
|
||||
s = Sample(10, 20)
|
||||
print(s.a, s.b) # 10 20
|
||||
foo(s)
|
||||
print(s.a, s.b) # 100 200
|
Loading…
Reference in New Issue
Block a user