设为首页收藏本站

Crossin的编程教室

 找回密码
 立即加入
楼主: crossin先生
打印 上一主题 下一主题

【每日一坑 4】 查找文件

[复制链接]

0

主题

0

好友

49

积分

新手上路

Rank: 1

楼主
发表于 2013-12-26 02:59:49 |显示全部楼层
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-

  3. import os, fnmatch

  4. def Findfiles(path, ext):
  5.         print 'Finding %s in %s' %(ext, path)
  6.         for root, dirs, files in os.walk(path):
  7.                 for file in files:
  8.                         if fnmatch.fnmatch(file, ext):
  9.                                 print 'Found %s in %s' %(file, root)


  10. print "\n\next format '*.jpg'\n\n"
  11. path = raw_input('Path: ')
  12. ext = raw_input('Ext: ')

  13. Findfiles(path, ext)
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即加入

QQ|手机版|Archiver|Crossin的编程教室 ( 苏ICP备15063769号  

GMT+8, 2024-5-6 04:50 , Processed in 0.018061 second(s), 21 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部