![](/img/trans.png)
[英]Python GTTS Error : AttributeError: 'NoneType' object has no attribute 'group'
[英]AttributeError: 'NoneType' object has no attribute 'group' error
try:
res = self.browser.open('https://login.facebook.com/login.php?login_attempt=1',form_data)
response = res.read()
self.fbid = re.search('https://www.facebook.com/(.*)\?sk=info',response)
self.fbid = re.search('https://www.facebook.com/(.*)',self.fbid.group(1))
self.fbid = re.search('https://www.facebook.com/(.*)',self.fbid.group(1))
except urllib2.HTTPError,e :
print "****exception****inside login error code: %s" % (e.code)
res.close()
except urllib2.HTTPError,e :
print "****exception****inside login error code: %s" % (e.code)
#print " server Response Code: %s " % (res.code)
我懂了
File "facebotv2.py", line 122, in login
self.fbid = re.search('https://www.facebook.com/(.*)',self.fbid.group(1))
AttributeError: 'NoneType' object has no attribute 'group'
第一次正则表达式搜索后, self.fbid
为None
。 这可能意味着您找不到匹配项。 如果你想防止错误,你可以有条件地只用if self.fbid != None
继续搜索初始搜索的结果if self.fbid != None
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.