Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
每当我在交互式运行 python 时加载模块时,我通常最终会这样做
some_variable = module.module_variable
获得更短的变量名。
有没有办法将此变量从模块加载到交互式范围。所以我不必重复?
简单的:
from module import function as func
好吧,这似乎是我所追求的。您只需要在主命名空间上设置变量。
import __main__ __main__.some_variable = module.module_variable