gpt4 book ai didi

python - AttributeError: 'NoneType' 对象没有属性 'group' 错误

转载 作者:行者123 更新时间:2023-11-30 23:10:46 25 4
gpt4 key购买 nike

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.fbidNone。这可能意味着您没有找到匹配项。如果您想防止出现错误,可以有条件地仅继续搜索初始搜索的结果 if self.fbid != None

关于python - AttributeError: 'NoneType' 对象没有属性 'group' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30565132/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com