全局变量管理模块 globalvar.py
def set_value(name, value):
global _global_dict
_global_dict = {}
_global_dict[name] = value
def get_value(name, defValue=None):
try:
return _global_dict[name]
except KeyError:
return defValue
set_value('score', 90)
2文件b.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import globalvar as gl
#name = gl.get_value('name')
score = gl.get_value('score')
print("%s" % (score))