CommonTips
globals()
bovenson@Dell:~/Git/notes/Python/Code/LearnPythonCode/tmp$ tree
.
├── a.py
└── b.py
0 directories, 2 files
bovenson@Dell:~/Git/notes/Python/Code/LearnPythonCode/tmp$ cat a.py
#!/usr/bin/python
# coding=utf-8
globals()["G"] = "Global Var"
bovenson@Dell:~/Git/notes/Python/Code/LearnPythonCode/tmp$ cat b.py
#!/usr/bin/python
# coding=utf-8
from a import *
print(globals()["G"])
bovenson@Dell:~/Git/notes/Python/Code/LearnPythonCode/tmp$ python b.py
Global Varimport
Date Time
date
time
最后更新于