单行Python导入的多个别名

时间:2016-04-07 15:43:28

标签: python import alias

我可以在Python中导入模块,在一行中为它提供两个或更多别名吗?

有两条线可以使用:

from time import process_time as tic
from time import process_time as toc

这不起作用,但我希望能够写出如下内容:

from time import process_time as tic,toc

2 个答案:

答案 0 :(得分:9)

你可以用

做到这一点
from time import process_time as tic, process_time as toc

答案 1 :(得分:3)

你可以做到

from time import process_time as tic

toc = tic