本文介绍了单行 Python 导入的多个别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以在 Python 中导入模块,在一行中给它两个或多个别名吗?
Can I import module in Python giving it two or more aliases in one line?
用两行就行了:
from time import process_time as tic
from time import process_time as toc
这不起作用,但我希望能够编写如下内容:
This doesn't work, but I would want to be able to write something like:
from time import process_time as tic,toc
推荐答案
你可以用
from time import process_time as tic, process_time as toc
这篇关于单行 Python 导入的多个别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!