以从某文件夹过滤出py文件为例:

法1:

import glob
import os
os.chdir(“./”)
for file in glob.glob(“*.py”):
print file

法2:

for file in os.listdir(“./”):
if file.endswith(“.py”):
print file

法3:

for root, dirs, files in os.walk(“./”):
for file in files:
if file.endswith(“.py”):
print os.path.join(root, file)

方法非原创,文责不负。嘿嘿

最新文章

  1. 函数floor(n)
  2. JSP复习整理(一)表单
  3. JVM相关
  4. string黑科技
  5. web开发中常用的技术体系
  6. 【转载】【Windows批处理IV】批量进行文件重命名
  7. 淘宝(阿里百川)手机客户端开发日记第八篇 Handler的使用方法
  8. Intellij IDEA新建一个EJB工程(二)
  9. Hibernate的配置
  10. Hibernate工作流程
  11. ios8指纹识别
  12. 性能测试分享:Jmeter的api监控工具解决方案
  13. php(面向对象的基本介绍)
  14. GDI+_SavePic
  15. 话说 SVN 与 Git 之间的区别
  16. Python--通过索引excel表将文件进行文件夹分类的脚本+读取指定目录下所有文件名的脚本
  17. iOS:二叉树多级表格的使用,使用三方库TreeTableView-master实现对json解析数据的递归遍历整理成树状结构
  18. CocoSourcesCS 1
  19. Java实现二叉树及相关遍历方式
  20. hdu 2167(状压dp)

热门文章

  1. Ubuntu gmake: command not found
  2. qpython3 读取安卓lastpass Cookies
  3. OC之160728
  4. Cloudera-Manager修改集群的IP
  5. Day9 summary
  6. HDU 4507 吉哥系列故事——恨7不成妻
  7. HDU5127 神坑题---vector 、 list 、 deque 的用法区别
  8. opencv配置(2.49)
  9. 使用样式“clear”和“overflow”消除浮动元素对环绕行框的影响
  10. Jenkins Job 自杀 groovy