python 核心编程第二版 9-9
来源:互联网 发布:中国海关进出口数据库 编辑:程序博客网 时间:2024/05/29 15:08
原题:
进入python标准库所在的目录。检查每个.py 文件看是否有doc,如果有,对其格式进行适当的整理归类。你的程序执行完毕后,应该生成一个漂亮的清单。里边列出哪些模块有文档字符串,以及文档字符串的内容,清单最后会附上哪些没有文档的字符串模块的名字
研究一下午,还是逻辑思维有漏洞。下面代码实现主要功能即可以将所有的文档的doc输出至文件并且能够找出有文档的py文件。
import osfile_list = []def getlist(path): global file_list path = os.path.abspath(path) for i in os.listdir(path): if os.path.isdir(path+'\\'+i): getlist(path+'\\'+i) elif os.path.splitext(i)[1] == '.py': file_list.append(path+'\\'+i)def checkdoc(): have_doc = [] file1 = open('t.txt', 'w') global file_list for file_tmp in file_list: str1 = '' print 'curr file: %s and per: %d ' % (file_tmp, file_list.index(file_tmp)) for line in open(file_tmp): if '"""' in line and str1 == '': str1 = 'file %s doc \n' % file_tmp have_doc.append(file_tmp) str1 += line elif file_tmp in have_doc: if '"""' in line: str1 += line str1 += '\n----------------------------------------\n' file1.write(str1) break else: str1 += line file1.close() print have_docif __name__ == '__main__': getlist('c:\\Python27\\Lib') checkdoc()
0 0
- python 核心编程第二版 9-9
- 《python 核心编程第二版第9章》习题
- Python核心编程(第二版)
- 《Python 核心编程》 第二版
- python核心编程第二版
- Python核心编程第二版学习笔记
- 《Python核心编程(第二版)》pdf
- 《Python核心编程》第二版学习总纲
- 《Python核心编程(第二版)》引读
- 《python 核心编程第二版》第五章
- python 核心编程 第二版 第二章 练习题
- Python核心编程 第二版 第二章 部分习题解答
- 《python核心编程第二版》第二章练习答案解析
- python核心编程 第二版 第二章 习题
- python核心编程第二版第二章习题
- Python核心编程(第二版)第二章练习题
- <python 核心编程第二版课后习题>第二章
- python核心编程第二版第二章学习笔记
- Android 中webp 的使用
- Qin Shi Huang's National Road System
- 安家了!第一篇自己的博客
- 关于英雄联盟中的英雄是如何寻找最佳路径的
- 局域网所有IP
- python 核心编程第二版 9-9
- Linux下Apache日志分析工具--AWStats安装使用
- 鸟哥的Linux私房菜(基础篇)- 附录 B: EXT2 / EXT3 文件系统
- move函数的用法
- [Object C]_[初级]_[文件修改创建时间和修改时间]
- Linux---我的第一个内核模块之Hello World
- Android进程间通讯AIDL详解
- The JSP specification requires that an attribute name is preceded by whitespace异常
- Hibernate常见问题