手机
当前位置:查字典教程网 >脚本专栏 >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下singleton模式的实现方法

python批量导出导入MySQL用户的方法

python基础教程之类class定义使用方法

Python GAE、Django导出Excel的方法

用python删除java文件头上版权信息的方法

python三元运算符实现方法

python实现问号表达式(?)的方法

python 实现插入排序算法

python实现倒计时的示例

精品推荐
分类导航