zoukankan      html  css  js  c++  java
  • python实用基本之--golb.glob

      python的强大的原因就是有很多非常实用的模块。今天用到了一个读取文件内容的小模块,做个记录:

    #!/usr/bin/python
    # -*- coding: utf-8 -*-
    
    import os, glob
    
    path = 'XXX'
    
    for infile in glob.glob(os.path.join(path, '*.png')):
        print infile
    
    print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
    
    for infile in sorted(glob.glob(os.path.join(path, '*.png'))):
        print infile
    
    print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
    
    for infile in sorted(glob.glob(os.path.join(path, '*.png')),key=os.path.getmtime):
        print infile
    print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") for infile in sorted(glob.glob(os.path.join(path, '*.png')),key=os.path.getsize): print infile
  • 相关阅读:
    抽象类和接口
    回调函数
    Spring Aop、拦截器、过滤器的区别
    事务
    SQL 模糊查询条件的四种匹配模式
    shell编程(二)
    shell编程(一)
    shell介绍
    字符验证码
    selenium
  • 原文地址:https://www.cnblogs.com/dylancao/p/9018635.html
Copyright © 2011-2022 走看看