如何将两个重叠的导入语句合并为一个



我能把下面两行代码写在一起吗?

from file import *
from file import foo as class_01

可以,但建议在模块中导入特定的类示例:

from shutil import make_archive as m_a,copy

是的,但这样做会导致代码可读性较差,因为它会向解释器引入未知名称。

相反,考虑导入所有需要的名称

from file import bar, foo as class_01

最新更新