手机
当前位置:查字典教程网 >脚本专栏 >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批量导出导入MySQL用户的方法

python三元运算符实现方法

Python下singleton模式的实现方法

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

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

python解析json实例方法

python处理文本文件并生成指定格式的文件

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

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

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

精品推荐
分类导航