我正在尝试导入email_extractor,但在除urllib2.URLError
之外的第一个除语句中出现错误,详情:
编辑该行时的PyCharm消息说:
"Python 3.6 does not support this syntax"
我该如何解决这个问题?
def getPage(url):
try:
f = urllib2.urlopen(url)
page = ""
for i in f.readlines():
page += i
date = f.info().getdate('Last-Modified')
if date == None:
date = (0, 0, 0)
else:
date = date[:3]
f.close()
return (page, date, f.url)
except urllib2.URLError, detail:
pass
return (None, (0,0,0), "")
答案 0 :(得分:0)
except
块只是一个错误的语法,它应该带有括号:
except (urllib2.URLError, detail):
pass
return (None, (0,0,0), "")