且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在python的一行中放置多个导入

更新时间:2022-06-22 22:03:10

不,你不能.对不起!

python import 语句仅支持一个模块一次导入语句.

The python import statement only supports one module to import statements from at a time.

如果你可以这样做,假设来说,以下意味着什么:

If you could do this, hypothetically speaking, what would the following mean:

from threading, multiprocessing import Thread, Condition, Lock

Condition 将从哪个模块导入?两个模块都定义了这样一个类.

what module would Condition be imported from? Both modules define such a class.

Python 更喜欢显式而不是隐式;您一次选择一个要从中导入的来源,因为这会导致最不意外和最清楚发生的事情.

Python prefers explicit over implicit; you select one source from which to import at a time as that results in the least surprise and the greatest clarity as to what is happening.