def square_sum(fn): def square(*args): n = args[0] fn(n * (n - 1) * (2 * n - 1) / 6) print("*" * 15) return fn(n * (n - 1) * (2 * n - 1) / 6) return square @square_sum # 等同于f=square_sum(sum_a) 返回一个新的方法square的引用 def f(a): print("3=", a) f(10) ############+ 等同于下面做的内容 ############+ # def f(a): # print("3=", a) # f = square_sum(f) # f(10)