zoukankan      html  css  js  c++  java
  • python标准库介绍——3 stat 模块详解

    == stat 模块 ==
    
    
    [Example 1-50 #eg-1-50] 展示了 ``stat`` 模块的基本用法, 
    这个模块包含了一些 ``os.stat`` 函数中可用的常量和测试函数.
    
    ====Example 1-50. Using the stat Module====[eg-1-50]
    
    ```
    File: stat-example-1.py
    
    import stat
    import os, time
    
    st = os.stat("samples/sample.txt")
    
    print "mode", "=>", oct(stat.S_IMODE(st[stat.ST_MODE]))
    
    print "type", "=>",
    if stat.S_ISDIR(st[stat.ST_MODE]):
        print "DIRECTORY",
    if stat.S_ISREG(st[stat.ST_MODE]):
        print "REGULAR",
    if stat.S_ISLNK(st[stat.ST_MODE]):
        print "LINK",
    print
    
    print "size", "=>", st[stat.ST_SIZE]
    
    print "last accessed", "=>", time.ctime(st[stat.ST_ATIME])
    print "last modified", "=>", time.ctime(st[stat.ST_MTIME])
    print "inode changed", "=>", time.ctime(st[stat.ST_CTIME])
    
    *B*mode => 0664
    type => REGULAR
    size => 305
    last accessed => Sun Oct 10 22:12:30 1999
    last modified => Sun Oct 10 18:39:37 1999
    inode changed => Sun Oct 10 15:26:38 1999*b*
    ```
  • 相关阅读:
    绿色版 notepad++ 添加鼠标右键菜单
    Scala 安装与配置
    Scala 神奇的下划线 _
    Kafka 安装部署
    Pulsar 下一代消息平台
    Sqoop 安装部署
    Flume 常用配置项
    Android-selector
    android- 9patch
    有关内存的思考题
  • 原文地址:https://www.cnblogs.com/xuchunlin/p/7748241.html
Copyright © 2011-2022 走看看