Python 装饰器示例

it2022-05-09  36

1 #!/usr/bin/env python 2 # _*_ coding: UTF-8 _*_ 3 # Author:taoke 4 def applePrice(func): 5 def otherfunc(): 6 print("apple : 5$") 7 func() 8 return otherfunc 9 10 @applePrice 11 def displayApple(): 12 print("apple : red") 13 14 displayApple()

apple : 5$apple : red

转载于:https://www.cnblogs.com/taoke2016/p/7471399.html

相关资源:python 装饰器的使用示例

最新回复(0)