单行Python导入上的多个别名


问题内容

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

用两行代码可以工作:

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

这是行不通的,但是我希望能够编写如下内容:

from time import process_time as tic,toc

问题答案:

你可以这样做

from time import process_time as tic, process_time as toc