从
The Python Tutorial – Modules
>模块:
A module is a file containing Python definitions and statements. The file name is the module name with the suffix .py appended.
>包装:
Packages are a way of structuring Python’s module namespace by using “dotted module names”.
如果您阅读import语句的文档,将提供更多详细信息,例如:
Python has only one type of module object, and all modules are of this
type, regardless of whether the module is implemented in Python, C, or
something else. To help organize modules and provide a naming
hierarchy, Python has a concept of packages.
You can think of packages as the directories on a file system and
modules as files within directories, but don’t take this analogy too
literally since packages and modules need not originate from the file
system. For the purposes of this documentation, we’ll use this
convenient analogy of directories and files. Like file system
directories, packages are organized hierarchically, and packages may
themselves contain subpackages, as well as regular modules.
It’s important to keep in mind that all packages are modules, but not
all modules are packages. Or put another way, packages are just a
special kind of module. Specifically, any module that contains a
__path__ attribute is considered a package.
因此,术语模块是指一个特定的实体:它是一个类,其实例是在python程序中使用的模块对象.类似地,它也被用来引用这些实例“被创建”的文件系统中的文件.
术语脚本用于指代要执行其目标的模块.它与“程序”或“应用程序”具有相同的含义,但通常用于描述简单和小程序(即,最多有几百行的单个文件).写一个脚本需要几分钟或几个小时.
术语库仅仅是一系列代码的通用术语,旨在为许多应用程序使用而设计.它提供了特定应用程序可以使用的一些通用功能.
当模块/包/其他东西被“发布”时,人们通常将其称为图书馆.通常,库包含一个包或多个相关包,但它甚至可以是单个模块.
库通常不提供任何特定功能,即您不能“运行库”.
根据上下文,API可以具有不同的含义.例如:
>它可以定义一个协议,如DB API或buffer protocol.
>它可以定义如何与应用程序交互(例如Python/C API)
>当与库/包相关时,它只是该库为其功能提供的接口(功能/类/常量等)
在任何情况下,API不是python代码.这可能是或多或少正式的描述.