2 回答

TA贡献1834条经验 获得超8个赞
Does the first import ("import os") mean that I'm only using a Module called "os"?
正如声明所暗示的那样,您正在导入OS 模块,因此您可以os
在 Python 脚本中使用该模块中的函数。
所以,现在您可以os.function()
在脚本中进行语句了。默认情况下,OS 模块与 Python 一起安装。这是关于 os 模块的信息。
Does the second import ("from flask import Flask") mean that I'm using the package "flask" and import the module "Flask"? If, e.g., there would be another import like "render_template", does that mean I'm using this module or is it a method from the module "Flask"?
这可能会令人困惑,因为函数名称和导入语句具有相同的名称。您只是从 Flask 模块中导入了函数Flask,而不是 Flask 模块中存在的所有函数。这可以出于多种原因完成。On 是为了简化调用函数。另一个可能是节省系统资源,因为您只是
os => means that I'm using the already imported module "os", right? path => means that I'm using an attribute from that module? abspath => means that I'm using a method within the "os" module called "abspath(value)"?
确切地说,请阅读文档以获取模块开发人员的解释。
Filename
这是Python 中文件名用法的说明。
添加回答
举报