在程序中看到有@,不知爲何?百度get!
def test(f):
print('before...')
f()
print('after...')
@test
def func():
print('func was called')
直接輸出結果:
before...
func was called
after...
由此可以看出函數調用過程,值得注意的是,f()就是func(),即test(f)中形參f(),而實參就是func()。
在程序中看到有@,不知爲何?百度get!
def test(f):
print('before...')
f()
print('after...')
@test
def func():
print('func was called')
直接輸出結果:
before...
func was called
after...
由此可以看出函數調用過程,值得注意的是,f()就是func(),即test(f)中形參f(),而實參就是func()。
class MetaCls(type): def __new__(cls, *args, **kwargs): print("in MetaCls") # return super(Meta