This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2, zlib | |
def GetContent(url, gzip=False, charset=None, headers=None): | |
"用于解析url内容" | |
try: | |
msg = None | |
if headers: | |
request = urllib2.Request(url=url, headers=headers) | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
class WithInContext(object): | |
"""docstring for WithInContext""" | |
def __init__(self,context): | |
print "WithInContext.__init__(%s)" % context | |
def do_something(self): | |
print "WithInContext.do_something" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from itertools import * | |
# imap | |
for i in imap(lambda x:x*2,xrange(5)): | |
print i | |
# starmap | |
values=[(1,2),(5,23),(8,9)] |
NewerOlder