码迷,mamicode.com
首页 > 其他好文 > 详细

查找目录下的文件

时间:2017-02-12 21:30:20      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:put   目录   log   list   curd   nbsp   port   目标   print   

 1 import os
 2 def check_file(start_dir, target): 
 3     os.chdir(start_dir)
 4     for each_file in os.listdir(os.curdir):
 5         if each_file == target:
 6             print(os.path.join(os.getcwd(), each_file))    
 7         if os.path.isdir(each_file):                    
 8             check_file(each_file,target)
 9             os.chdir(os.pardir)
10 
11 
12 start_dir = input(请输入待查找的初始目录:)
13 target = input(请输入要查找的目标文件:)
14 check_file(start_dir, target)

 

查找目录下的文件

标签:put   目录   log   list   curd   nbsp   port   目标   print   

原文地址:http://www.cnblogs.com/themost/p/6391659.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!