python之生成文件列表(链接方式)

## dirList.py


import os
"""
Author: Feihf
Date  : 2014-5-30
"""

"""	get Header """
def printHead():
	print ""
	print ""
	print ''

"""	walk the certain dir,and process the dirname """
def printBody(dirname):
    try:
        ls=os.listdir(dirname)
    except:
        print('access deny')
    else:
        for file in ls:
            if file == 'index.html':
                continue
            temp=os.path.join(dirname,file)
            if(os.path.isdir(temp)):
                print '%s[+]
' % (file,file,file) else: print '%s
' % (file,file) """ get Header """ def printEnd(): print "" print "" """ Main""" dir = os.getcwd() printHead() printBody(dir) printEnd()



@@用法

dirList.py

生成文件的列表(html的格式)

你可能感兴趣的:(Python)