• 2023-12-05How to use Python Decorators_0
    AuthorizationLogging通过装饰器可以来打印日志:fromfunctoolsimportwrapsdeflogit(func):@wraps(func)defwith_logging(*args,**kwargs):print(func.__name__+"wascalled")returnfunc(*args,**kwargs)returnwith_loggin
  • 2023-12-05How to use Python Decorators_1
    加入了写入Log文件的Decorators:fromfunctoolsimportwrapsdeflogit(logfile='out.log'):deflogging_decorator(func):@wraps(func)defwrapped_function(*args,**kwargs):log_string=func.__name__+"wascalled&qu
  • 2023-12-05Python Decorators Brief
    参考的URL:https://www.runoob.com/w3cnote/python-func-decorators.htmlDecorators-->Pythonic切入点:函数--函数中的函数--函数中返回函数--将函数作为参数传递给另一个函数(简单装饰器)@符号-->将装饰器放到需要被装饰的函数前;@wraps()-->函数即使被装饰器装饰,也
  • 2023-11-17测试某个python库是否正常导入
    我这里的测试代码:python-c"importmagenta"出现错误:/Users/ghj1976/opt/anaconda3/envs/magenta/lib/python3.7/site-packages/librosa/util/decorators.py:9:NumbaDeprecationWarning:Animportwasrequestedfromamodulethathasmovedlocation.Importrequested
  • 2023-10-11测试某个python库是否正常导入
    我这里的测试代码:python-c"importmagenta"出现错误:/Users/ghj1976/opt/anaconda3/envs/magenta/lib/python3.7/site-packages/librosa/util/decorators.py:9:NumbaDeprecationWarning:Animportwasrequestedfromamodulethathasmovedlocation.Importreques
  • 2023-06-11python: Decorators
      #装饰器defprintpy(func):definner_func():func()print("hellopython!GeovinDu")returninner_func#@装饰器@printpydefprinthello():print("helloworld!")#调用printhello()'''De
  • 2023-03-16设计模式之装饰者模式,奶茶店场景
    //Seehttps://aka.ms/new-console-templateformoreinformationusingSystem.Drawing;/*装饰者模式,不改变实现类的情况下,动态给实现类增加新功能,这里使用聚合
  • 2022-11-16python中Decorators的用法
    最近看别人写的一个源码,发现有很多地方用到了@符号。有的还传入了参数。觉得这个好像很强大。所以就在网上找了一些相关的资料。也有一个专门讲python的网页也不错:htt
  • 2022-09-21内存管理——记忆集和读写屏障
    记忆集和读写屏障由于对堆使用了分代管理,所以在对新生代进行GC的时候需要将老年代对新生代中对象的引用也当做根来看待,所以在根标记的过程中也需要对老年代的引用进行标记