當前位置:首頁 » 編程語言 » 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.'

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:578
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:872
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:567
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:751
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:669
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:995
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:240
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:99
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:791
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:697