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()

你写的语法没有错,试试看这样可以不?
def a(func):
print('a)
return func
@a
def b():
print('b')
b()
Python2.5以后才有装饰器,看看Python版本对不?
我在Python2.6下是可以运行的。
温馨提示:内容为网友见解,仅供参考
第1个回答  2012-07-11
print('a)少半拉引号
相似回答