2 回答

TA貢獻(xiàn)1834條經(jīng)驗(yàn) 獲得超8個(gè)贊
Does the first import ("import os") mean that I'm only using a Module called "os"?
正如聲明所暗示的那樣,您正在導(dǎo)入OS 模塊,因此您可以os
在 Python 腳本中使用該模塊中的函數(shù)。
所以,現(xiàn)在您可以os.function()
在腳本中進(jìn)行語句了。默認(rèn)情況下,OS 模塊與 Python 一起安裝。這是關(guān)于 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"?
這可能會(huì)令人困惑,因?yàn)楹瘮?shù)名稱和導(dǎo)入語句具有相同的名稱。您只是從 Flask 模塊中導(dǎo)入了函數(shù)Flask,而不是 Flask 模塊中存在的所有函數(shù)。這可以出于多種原因完成。On 是為了簡化調(diào)用函數(shù)。另一個(gè)可能是節(jié)省系統(tǒng)資源,因?yàn)槟皇?/p>
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)"?
確切地說,請(qǐng)閱讀文檔以獲取模塊開發(fā)人員的解釋。
Filename
這是Python 中文件名用法的說明。
添加回答
舉報(bào)