【发布时间】:2022-11-24 17:16:07
【问题描述】:
import re
phonenumregex=re.compile(r'ddd-ddd-dddd')
mo=phonenumregex.search("My number is 415-555-4242")
print("Phone Number found: " + mo.group())
#it gives me this error.
AttributeError: 'NoneType' object has no attribute 'group'
我在原始字符串中将格式设置为 ddd-ddd-dddd。并期望得到 415-555-4242 作为回报
【问题讨论】: