码迷,mamicode.com
首页 > 编程语言 > 详细

Python 路径

时间:2015-02-05 20:18:43      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:

#!\usr\bin\env python
# -*- coding: utf-8 -*-

import os

def printFiles(folder):
	#获取当前路径下所有文件
	fileList = os.listdir(folder)

	for file in fileList:
		# 如果不是是路径
		# if not os.path.isdir(file):
		# 如果是路径,就打印出来
		if os.path.isdir(file):
			#格式化输出
			print(‘===%s===‘ % file)
			printFiles(file)
		else:
			print(‘文件:\t‘,file)

#获取当前路径
curPath = os.getcwd()
printFiles(curPath)

  

Python 路径

标签:

原文地址:http://www.cnblogs.com/pengzhong/p/PythonPath.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!