I will try to answer this without using terms the earliest of beginners would use, and explain why or how they used differently, along with the most "official" and/or most understood or uniform use of the terms.
It can be confusing, and I confused myself thinking too hard, so don't think too much about it. Anyways context matters, greatly.
Library - Most often will refer to the general library or another collection created with a similar format and use. The General Library is the sum of 'standard', popular and widely used Modules, which can be thought of as single file tools, for now or shortcuts making things possible or faster. The general library is an option most people enable when installing Python. Because it has this name "Python General Library" it is used often with similar structure and ideas. Which is simply to have a bunch of Modules, maybe even packages grouped together, usually in a list. The list is usually to download them. Generally, it is just related files, with similar interests. That is the easiest way to describe it.
模块 -
模块指的是一个文件。该文件包含脚本,并且文件名就是模块的名称,Python文件以.py结尾。文件中只包含一些代码,这些代码运行在一起可以实现某些功能,通过使用函数、字符串等。
你可能经常看到的主要模块很受欢迎,因为它们是特殊的模块,可以从其他文件/模块获取信息。
这很令人困惑,因为文件名和模块名相同,只需去掉.py即可。实际上,它只是由某人编写的可用作快捷方式的代码,使某些事情更容易或可能发生。
包 - 这是一个术语,有时用于一般性描述,但上下文很重要。从我的经验来看,最常见的用法是将多个模块(或文件)分组在一起。它们被分组在一起的原因可能有几个,这就是上下文的作用。
以下是我注意到的
包(们)术语的使用方式。它们是一组下载、创建和/或存储的模块。这些都可能是真实的,也可能只有其中之一,但实际上它只是引用其他文件的文件,需要以正确的结构或格式存在,而整个总和就是该软件包本身,已安装或可能已包含在Python通用库中。一个包可以包含模块(.py文件),因为它们彼此依赖,有时可能无法正常工作。每个部分(模块/文件)的共同目标始终存在,并且所有部分的总和就是该软件包本身。
在Python中,大多数情况下,包是模块,因为包名是用于连接所有部分的模块名称。因此,您可以输入一个包,因为它是一个模块,还允许它调用其他模块,这些模块不是包,因为它们仅执行特定功能或任务,不涉及其他文件。包有一个目标,每个模块一起努力实现最终目标。
大多数混淆源于文件名或前缀作为模块名再次用作包名。
请记住,模块和包可以安装。库通常是一个通用术语,用于列出或格式化一组模块和包。就像Python的通用库一样。层次结构不起作用,API实际上不属于任何特定位置,如果是的话,它们可以涉及脚本、模块和包中的任何地方,世界图书馆是如此通用的词,可以轻松应用于许多事物,也使得API能够在其上方或下方。有些模块可以基于其他代码,这是我认为它与纯Python相关的讨论唯一相关的情况。