应该是这样的:
def add_new_url(self, url):
if url is None:
raise Exception # 为None抛出异常
else:
self.new_urls.add(url)
def add_new_urls(self, urls):
if urls is None:
raise Exception
for url in urls:
try:
self.add_new_url(url)
except Exception:
continue # 遇到为None的直接忽视
def add_new_url(self, url):
if url is None:
raise Exception # 为None抛出异常
else:
self.new_urls.add(url)
def add_new_urls(self, urls):
if urls is None:
raise Exception
for url in urls:
try:
self.add_new_url(url)
except Exception:
continue # 遇到为None的直接忽视
2016-01-06
楼下的直接写第三段的都是错的,没有import http.cookiejar绝对都是http not defined
2016-01-05