文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>python遍历文件夹

python遍历文件夹

时间:2005-07-19  来源:jerryfleming

根据别人的算法用python实现

#!/usr/bin/python

from os.path import basename, isdir
from os import listdir

def traverse(path, depth=0):
 prefix =  depth* '| ' + '|_'
 if(isdir(path)):
  print prefix, basename(path)
  for item in listdir(path):
   traverse(path+'/'+item, depth+1)
 else:
  print prefix, basename(path)

if __name__ == '__main__':
 traverse('./')

相关阅读 更多 +
排行榜 更多 +
Meme的毒药游戏手机版下载

Meme的毒药游戏手机版下载

休闲益智 下载
野兽战争模拟器手机版下载

野兽战争模拟器手机版下载

策略塔防 下载
山海经卡牌射击手游下载

山海经卡牌射击手游下载

飞行射击 下载