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

熱點內容
超級訪問羅大佑 發布:2025-07-11 07:43:33 瀏覽:387
邁騰有什麼安全配置 發布:2025-07-11 07:42:40 瀏覽:644
c語言字元逆序 發布:2025-07-11 07:41:57 瀏覽:923
怎麼配置交換機的console密碼 發布:2025-07-11 07:41:57 瀏覽:4
東芝存儲卡視頻 發布:2025-07-11 07:41:55 瀏覽:541
cs16為什麼搜不到區域網伺服器 發布:2025-07-11 07:41:21 瀏覽:913
php項目如何上傳伺服器 發布:2025-07-11 07:35:35 瀏覽:182
壓縮機4井 發布:2025-07-11 07:34:57 瀏覽:726
win7訪問共享 發布:2025-07-11 07:34:48 瀏覽:279
telnetlinux退出 發布:2025-07-11 07:29:46 瀏覽:791