摘要: 本博客列出的答案不是来自官方资源,是我自己做的练习,可能有误。9-1.文件过滤。显示一个文件的所有行,忽略以井号(#)开头的行。这个字符被用做Python,Perl,Tcl,等大多数脚本文件的注释符号。附加题:处理不是第一个字符开头的注释。【答案】(a)代码如下:fobj = open('c:\Python Test\P_1.txt')for eachLine in fobj: if eachLine[0] != '#': print eachLine,fobj.close()文件P_1.txt具体是:applebanana#orangeorange#orang 阅读全文
posted @ 2012-01-19 08:58 balian 阅读(1717) 评论(0) 推荐(0) 编辑