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

熱點內容
c語言strupr 發布:2025-09-19 09:47:52 瀏覽:682
路由器密碼是什麼啊 發布:2025-09-19 09:23:25 瀏覽:701
天蠍腳本輔助 發布:2025-09-19 09:22:31 瀏覽:256
官服光遇賬號和密碼在哪裡看 發布:2025-09-19 08:57:15 瀏覽:649
傳奇切割機腳本 發布:2025-09-19 08:35:46 瀏覽:74
博科存儲交換機配置 發布:2025-09-19 08:34:31 瀏覽:138
xp共享win7沒有訪問許可權 發布:2025-09-19 08:29:15 瀏覽:288
cmd運行python程序 發布:2025-09-19 08:16:07 瀏覽:298
如何給你的安卓手機正確充電 發布:2025-09-19 08:15:18 瀏覽:850
vs2010怎麼寫c語言 發布:2025-09-19 07:31:05 瀏覽:882