单行Python导入的多个别名 [英] Multiple aliases on one-line Python import
本文介绍了单行Python导入的多个别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以在Python中导入模块,在一行中为它添加两个或更多别名吗?
有两行可行:
从时间导入process_time到tic
从时间导入process_time为toc
这不起作用,但我希望能够写出如下内容:
从时间导入process_time为tic,toc
解决方案
你可以从时间导入process_time作为tic,process_time作为toc
Can I import module in Python giving it two or more aliases in one line?
With two lines this works:
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
解决方案
You can do that with
from time import process_time as tic, process_time as toc
这篇关于单行Python导入的多个别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文