headers = {'Authorization': 'OAuth '+access_token}
req = urllib.request.Request('https://www.googleapis.com/oauth2/v1/userinfo',None, headers)
try:
res = urlopen(req)
except URLError as e:
if e.code == 401:
# Unauthorized - bad token
session.pop('access_token', None)
return redirect(url_for('login'))
return res.read()
return res.read()
UnboundLocalError:局部变量' res'在分配前引用
我该如何解决?