简体   繁体   English

SQLAlchemy:有“全球”进口声明吗?

[英]SQLAlchemy: is there a “global” import statement?

SQLAlchemy has a lot of import statements, eg SQLAlchemy有很多import语句,例如

from SQLAlchemy import .....

Is there a "global" import statement that imports everything?是否有导入所有内容的“全局”导入语句?

The syntax语法

from <module> import <symbol>

is just one othe ways python offers to import libraries.这只是 python 提供的导入库的其他方式之一。 Asexplained in the official documentation the expression正如官方文档中解释的表达式

import module [as identifier]

is the common way to import all symbols of a module.是导入模块所有符号的常用方法。


Alternatively you can import all symbols of a specific library using * :或者,您可以使用*导入特定库的所有符号:

>>> from sqlalchemy import *
>>> sqlalchemy.__version__
'1.3.17'
>>> engine = create_engine('sqlite:///:memory:', echo=True)
>>>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM