Being a beginner in python I might be missing out on some kind of basics. But I was going through one of the codes from a project and happened to face this :
AttributeError: 'NoneType' object has no attribute 'groupdict'
Following is the section of code,re-phrased though,still this does result in the same problem.
import re
fmt = (r"\+((?P<day>\d+)d)?((?P<hrs>\d+)h)?((?P<min>\d+)m)?"
r"((?P<sec>\d+)s)?((?P<ms>\d+)ms)?$")
p = re.compile(fmt)
match = p.search('Total run time: 9h 34m 9s 901ms realtime, 7h 6m 29s 699ms uptime')
try:
d = match.groupdict()
except IndexError:
print("exception here")