#-*-coding:utf-8-*-#author:baoshan#Functiondecoratorwithparametersdefsay_hello(country):defwrapper(func):defdeco(*args,**kwargs):ifcountry=='china':print('Hello!')elifcountry=='america':print('hello')else:returnfunc(*args,**kwargs)returndecoreturnwrapper@say_hello('中国')defchinese():print('我来自中国。')@say_hello('美国')defamerica():print('我来自美国。')america()print('-'*20)Chinese()输出结果:helloIamfromAmerica.--------------------你好!我来自中国。延伸阅读:https://www.cnblogs.com/serpe...https://www.cnblogs.com/liany...
