11智能在线
新记
python在引用其他模块下的decorator的函数时,怎么老是提示 global name 'a' not defiend,如:
a.py
def a(func):
print('a)
return func
b.py
import a
@a.a
def b():
print('b')
b()
举报该文章
相关建议 2012-07-10
你写的语法没有错,试试看这样可以不?
def a(func):
print('a)
return func
@a
def b():
print('b')
b()
Python2.5以后才有装饰器,看看Python版本对不?
我在Python2.6下是可以运行的。
温馨提示:内容为网友见解,仅供参考
当前网址:
https://11.t2y.org/zz/ss7m744sf.html
其他看法
第1个回答 2012-07-11
print('a)少半拉引号
相似回答
大家正在搜
相关问题
python 在函数里面定义的变量,在外面就不能用了?我不是...
Python一个模块怎样修改另一个模块定义的全局变量值?
python中怎么在自定义函数调用另外一个函数中的参数
请教一个Python函数之间相互调用报错的问题
python3.2.2使用apply函数时为什么报NameE...
python问题,为什么出现builtins.NameErr...
python如何引用其他模块中类的方法中的变量?
这段python代码有问题,请大神帮我看下