Home  >  Q&A  >  body text

Python模块导入方式疑问?

import sqlalchemy
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import sessionmaker

sqlalchemy模块已经被导入,为什么下面还需要以“.”号连接导入子模块?
我有看到说某些特定的子模块必须以“.”号连接的形式明确标出才能够导入?如果是,那些子块有这种需要,我在哪里可以查找呢?

ringa_leeringa_lee2766 days ago267

reply all(1)I'll reply

  • PHPz

    PHPz2017-04-18 09:42:55

    from a import b, b is a class, function or constant, from a.b import c, b is a package (module). Simply put, classes and functions can be used directly, and packages have their own classes and functions

    reply
    0
  • Cancelreply