你能在 Python 中为导入的模块定义别名吗? [英] Can you define aliases for imported modules in Python?
本文介绍了你能在 Python 中为导入的模块定义别名吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Python 中,是否可以为导入的模块定义别名?
In Python, is it possible to define an alias for an imported module?
例如:
import a_ridiculously_long_module_name
...所以它的别名是short_name".
...so that is has an alias of 'short_name'.
推荐答案
import a_ridiculously_long_module_name as short_name
也适用于
import module.submodule.subsubmodule as short_name
这篇关于你能在 Python 中为导入的模块定义别名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文