python之生成文件列表(链接方式)
2015-11-18 22:47
567 查看
## dirList.py
@@用法
dirList.py
生成文件的列表(html的格式)
import os """ Author: Feihf Date : 2014-5-30 """ """ get Header """ def printHead(): print "<html>" print "<head><style>a{border:1px solid #FF0099; font-size: 200%;}</style></head>" print '<body style="background-color:rgb(200,237,204);">' """ 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 '<a style="background-color:pink;" href="./%s/">%s</a><a href="./%s/readMe.txt">[+]</a><br/>' % (file,file,file) else: print '<a href="./%s">%s</a><br/>' % (file,file) """ get Header """ def printEnd(): print "</body>" print "</html>" """ Main""" dir = os.getcwd() printHead() printBody(dir) printEnd()
@@用法
dirList.py
生成文件的列表(html的格式)
相关文章推荐
- python之批量重命名目录文件
- 练习PYTHON之EPOLL
- python之转换源码后缀名为txt后缀名
- python urllib模块
- leetcode Integer to Roman python
- python之模块hashlib(提供了常见的摘要算法,如MD5,SHA1等等)
- 练习PYTHON之EVENTLET
- python之WebSocket的开发
- 练习PYTHON之GEVENT
- Python pexpect出现错误‘module have no attribute "spawn" 解决办法
- Python/scikit-learn机器学习库(决策树)
- LeetCode OJ 系列之78 Subsets --Python
- python之string操作汇总
- python之实现ftp上传下载代码(含错误处理)
- python里面的函数参数
- 练习PYTHON协程之GREENLET
- python之模块ftplib(实现ftp上传下载代码)
- python_2
- [Python标准库]string——文本常量和模板
- python之模块ftplib(FTP协议的客户端)