python搜索指定目录的方法
本文实例讲述了python搜索指定目录的方法。分享给大家供大家参考。具体分析如下:
#-------------------------------------
#Name:search_directory.py
#Author:KevinHarris
#LastModified:02/13/04
#Description:ThisPythonscriptdemonstrateshowtouseos.walk()
#towalkthroughadirectoryhierarchy
#andlisteverything
#found.
#-------------------------------------
importos
forroot,dirs,filesinos.walk(os.curdir):
print("root="+root)
forfileinfiles:
print("file="+file)
fordirindirs:
print("dir="+dir)
print("\n")
input('\n\nPressEntertoexit...')
希望本文所述对大家的Python程序设计有所帮助。
热门推荐
2 孙媳妇祝福语简短
10 朋友弟弟生日祝福语简短
11 元旦在岗祝福语简短精辟
12 省运会童声祝福语大全简短
13 学生毕业季祝福语简短
14 日常祝福语简短语客户
15 侄儿生日祝福语简短独特
16 蛋糕平安健康祝福语简短
17 怎样给人送祝福语简短
18 网友婚姻祝福语大全简短