我問另一個問題python flask how to pass a dynamic parameter to a decorator,我得到了答案。 我現在正在使用燒瓶,並使用flask-restful api,這將很容易建立寧靜的API 和我的代碼是這樣的。 class ShopCategoryListAPI(Resource):
#@redis_hash_shop(shop_id=L
這是簡單的裝飾帶參數: app.py from __future__ import print_function
import time
def newdecorator(arg1):
def benchmarking(funct):
#The argument is accessible here
print("this is the value of a
我有一個python中的單個參數函數的列表,我想要應用相同的縮放/翻譯操作。 規模/翻譯爲一個函數f(x)將如下所示: F'(X,A,B,C,d)= A + B * F(C *(X - d )) 因此,例如,如果我的原始函數被定義爲: F(X)= 3 * X 我想修改它是: F'(X ,a,b,c,d)= a + b *(3 *(c *(x-d))) 理想情況下使用裝飾器(或其他可重用的操作,我可