當前位置:首頁 » 編程語言 » 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-03-06 11:07:26 瀏覽:110
有鎖安卓手機有什麼壞處 發布:2025-03-06 11:00:20 瀏覽:575
dvwa上傳 發布:2025-03-06 10:46:58 瀏覽:699
新款榮放低配有哪些新配置 發布:2025-03-06 10:41:29 瀏覽:791
如何給文件上加密 發布:2025-03-06 10:33:09 瀏覽:370
python類super 發布:2025-03-06 10:32:16 瀏覽:74
編程代碼構成 發布:2025-03-06 10:23:58 瀏覽:955
如何看一台電視配置 發布:2025-03-06 10:18:08 瀏覽:253
如何查筆記本電腦配置 發布:2025-03-06 10:17:29 瀏覽:744
安卓手機消息彈幕怎麼設置 發布:2025-03-06 10:10:22 瀏覽:186