Django@method\u decorator从Python 2更改为3?
我目前正在进行代码从Python2到Python3的迁移。我用的是Django,看起来我遗漏了什么 我使用的是来自Django的decorator@method\u decorator(func)。我的功能是这样定义的:Django@method\u decorator从Python 2更改为3?,django,python-3.x,python-2.7,migration,Django,Python 3.x,Python 2.7,Migration,我目前正在进行代码从Python2到Python3的迁移。我用的是Django,看起来我遗漏了什么 我使用的是来自Django的decorator@method\u decorator(func)。我的功能是这样定义的: @decorator func(action_meth, *args, **kwargs): result = action_meth(*args, **kwargs) # do # something # with # result
@decorator
func(action_meth, *args, **kwargs):
result = action_meth(*args, **kwargs)
# do
# something
# with
# result
我的问题是Python2和Python3中的args值不同,因此args不能用作我的action_meth的参数(我得到错误:action_meth使用2个位置参数,但给出了3个)
首先,这段代码在Python2中运行良好。但是我在互联网上找不到任何关于Python 3迁移的信息。
而且我敢肯定它来自Djangos method_decorator。。。那么,有人知道这个特性是否发生了变化吗
这是我能得到的样本
在Python 2中:
打印(args)=>([u'ID']),
在Python 3中:
打印(参数)=>选择字段A、字段B、…、字段Z。。。。;args=(ID,)
谢谢你的时间 没有任何变化,这是代码中更深层次的另一个问题
也为这个问题的糟糕表述感到遗憾 没有任何变化,这是代码中更深层次的另一个问题 也为这个问题的糟糕表述感到遗憾