_global.py 494 B

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