當前位置:首頁 » 編程語言 » python包和模塊

python包和模塊

發布時間: 2023-12-04 01:26:23

python中的模塊,庫,包有什麼區別

1.python模塊是:

python模塊:包含並且有組織的代碼片段為模塊。

表現形式為:寫的代碼保存為文件。這個文件就是一個模塊。sample.py 其中文件名smaple為模塊名字。

關系圖:

3.庫(library)

庫的概念是具有相關功能模塊的集合。這也是Python的一大特色之一,即具有強大的標准庫、第三方庫以及自定義模塊。

② Python模塊的幾種類型簡介

view plain to clipboardprint?
import os
import stat
import time<DIV></DIV>

fileStats = os.stat ( 'test.txt' )
fileInfo = {
'Size' : fileStats [ stat.ST_SIZE ],
'LastModified' : time.ctime ( fileStats [ stat.ST_MTIME ] ),
'LastAccessed' : time.ctime ( fileStats [ stat.ST_ATIME ] ),
'CreationTime' : time.ctime ( fileStats [ stat.ST_CTIME ] ),
'Mode' : fileStats [ stat.ST_MODE ]
}

for infoField, infoValue in fileInfo:
print infoField, ':' + infoValue
if stat.S_ISDIR ( fileStats [ stat.ST_MODE ] ):
print 'Directory. '
else:
print 'Non-directory.'

import os
import stat
import time

fileStats = os.stat ( 'test.txt' )
fileInfo = {
'Size' : fileStats [ stat.ST_SIZE ],
'LastModified' : time.ctime ( fileStats [ stat.ST_MTIME ] ),
'LastAccessed' : time.ctime ( fileStats [ stat.ST_ATIME ] ),
'CreationTime' : time.ctime ( fileStats [ stat.ST_CTIME ] ),
'Mode' : fileStats [ stat.ST_MODE ]
}

for infoField, infoValue in fileInfo:
print infoField, ':' + infoValue
if stat.S_ISDIR ( fileStats [ stat.ST_MODE ] ):
print 'Directory. '
else:
print 'Non-directory.'

熱點內容
php辦公系統 發布:2025-07-19 03:06:35 瀏覽:896
奧德賽買什麼配置出去改裝 發布:2025-07-19 02:53:18 瀏覽:38
請與網路管理員聯系請求訪問許可權 發布:2025-07-19 02:37:34 瀏覽:187
ipad上b站緩存視頻怎麼下載 發布:2025-07-19 02:32:17 瀏覽:842
phpcgi與phpfpm 發布:2025-07-19 02:05:19 瀏覽:525
捷達方向機安全登錄密碼是多少 發布:2025-07-19 00:57:37 瀏覽:690
夜魔迅雷下載ftp 發布:2025-07-19 00:39:29 瀏覽:97
增值稅票安全接入伺服器地址 發布:2025-07-19 00:20:45 瀏覽:484
solidworkspcb伺服器地址 發布:2025-07-18 22:50:35 瀏覽:820
怎麼在堆疊交換機里配置vlan 發布:2025-07-18 22:42:35 瀏覽:628