Chinaunix首页 | 论坛 | 博客
  • 博客访问: 344224
  • 博文数量: 59
  • 博客积分: 2000
  • 博客等级: 大尉
  • 技术积分: 646
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-14 12:09
文章分类

全部博文(59)

文章存档

2009年(2)

2008年(57)

我的朋友

分类: Python/Ruby

2008-12-08 22:45:38

import os
import time
file = "samples/sample.jpg"
def dump(st):
    mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime = st
    print "- size:", size, "bytes"
    print "- owner:", uid, gid
    print "- created:", time.ctime(ctime)
    print "- last accessed:", time.ctime(atime)
    print "- last modified:", time.ctime(mtime)
    print "- mode:", oct(mode)
    print "- inode/dev:", ino, dev
# get stats for a filename
st = os.stat(file)
print "station", file
dump(st)
print st

# get stats for an open file
fp = open(file)
st = os.fstat(fp.fileno())
print "fstat", file
dump(st)

print st.st_ctime


201865413.8952832



import os
>>> o=os.stat(r'F:\\Xunlei\160103.doc')
>>> t=o.st_ctime
>>> t
1202624180.046875
>>> print type(t)

>>> import time
>>> r=time.ctime(t)
>>> r
'Sun Feb 10 14:16:20 2008'
>>> s=time.gmtime(t)
>>> s
(2008, 2, 10, 6, 16, 20, 6, 41, 0)
>>> time.strftime("%a, %d %b %Y %H:%M:%S +0000", s)
'Sun, 10 Feb 2008 06:16:20 +0000'



>>> import time
>>> time.localtime(statinfo.st_ctime)
(
200821193013432, 0)


阅读(1880) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~