#encoding:utf-8
#!/usr/bin/env python
from urllib import urlretrieve
from time import ctime sleep
from random import randint
from operator import add mul
from functools import partial
def firstNonBlank(lines):
for eachLine in lines:
if not eachLine.strip():
continue
else:
#sleep(1)
#print eachLine
return eachLine
def firstLast(webpage):
print ‘webpage= ‘ webpage
f = open(webpage)
lines = f.readlines()
#print ‘lines=‘lines
f.close()
print firstNonBlank(lines)lines.reverse()
print firstNonBlank(lines)
def download(url=‘http://www.baidu.com/‘ process=firstLast):
try:
retval = urlretrieve(url)[0]
print ‘retval= ‘retval
except IOError:
retval = None
if retval: # do some processing
process(retval)
def newfoo(
评论
共有 条评论