Python2.x学习小记 2014-12-11 Python Python 不定时更新,不一定适合3.X,但一定适合2.7。一、Python中的装饰器 1234567891011121314151617def main(): def decorator_with_params(arg_of_decorator): print arg_of_decorator print '1' def newDecorator(func): print '3' print func.__name__ return func(1,2) print '2' return newDecorator @decorator_with_params("deco_args") def foo(a,b): print 'foo('+str(a)+','+ str(b)+') is called'if __name__ == '__main__': main() 输出结果: 123456deco_args123foofoo(1,2) is called Newer 冲茶之道 Older mongodb在python中的应用——利用pymongo和mongoengine