_global.py 453 B

123456789101112131415161718192021222324252627282930
  1. import gc
  2. import logging
  3. def _init():
  4. global global_dict
  5. global_dict = {}
  6. def update(_dict):
  7. # 定义一个全局变量
  8. try:
  9. global_dict.update(_dict)
  10. except Exception as e:
  11. return
  12. def get(key):
  13. # 获得一个全局变量
  14. try:
  15. value = global_dict.get(key)
  16. except Exception as e:
  17. value = None
  18. return value
  19. def _del():
  20. global global_dict
  21. del global_dict
  22. gc.collect()