手机
当前位置:查字典教程网 >脚本专栏 >python >python搜索指定目录的方法
python搜索指定目录的方法
摘要:本文实例讲述了python搜索指定目录的方法。分享给大家供大家参考。具体分析如下:#----------------------------...

本文实例讲述了python搜索指定目录的方法。分享给大家供大家参考。具体分析如下:

#------------------------------------- # Name: search_directory.py # Author: Kevin Harris # Last Modified: 02/13/04 # Description: This Python script demonstrates how to use os.walk() # to walk through a directory hierarchy # and list everything # found. #------------------------------------- import os for root, dirs, files in os.walk( os.curdir ): print( "root = " + root ) for file in files: print( "file = " + file ) for dir in dirs: print( "dir = " + dir ) print( "n" ) input( 'nnPress Enter to exit...' )

希望本文所述对大家的Python程序设计有所帮助。

【python搜索指定目录的方法】相关文章:

Python实现扫描指定目录下的子目录及文件的方法

python列表去重的二种方法

python生成指定尺寸缩略图的示例

Python获取脚本所在目录的正确方法

python连接sql server乱码的解决方法

python实现网页链接提取的方法分享

python脚本实现查找webshell的方法

python3访问sina首页中文的处理方法

Python下singleton模式的实现方法

Python中针对函数处理的特殊方法

精品推荐
分类导航