Python模块的几种类型简介
发布网友
发布时间:2022-04-22 22:42
我来回答
共1个回答
热心网友
时间:2022-05-10 08:36
view plaincopy 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.'