Chinaunix首页 | 论坛 | 博客
  • 博客访问: 485565
  • 博文数量: 173
  • 博客积分: 4112
  • 博客等级: 上校
  • 技术积分: 1577
  • 用 户 组: 普通用户
  • 注册时间: 2010-02-26 10:12
文章分类

全部博文(173)

文章存档

2012年(1)

2010年(172)

我的朋友

分类: Python/Ruby

2010-09-25 16:38:55

from urllib import urlretrieve
def firstNonBlank(lines):
    for eachLine in lines:
        if not eachLine.strip():
            continue
    else:
        return eachLine
   
def firstLast(webpage):
    f=open(webpage)
    lines=f.readlines()
    f.close
    print firstNonBlank(lines),
    lines.reverse()
    print firstNonBlank(lines),
   
def download(url= '',process=firstLast):
    try:
        retval = urlretrieve(url) [0]
    except IOError:
        retval = None
    if retval:
        process(retval)
           
if __name__ == '__main__':
    download()
阅读(2094) | 评论(0) | 转发(0) |
0

上一篇:python 数字练习

下一篇:os模块

给主人留下些什么吧!~~