おせわになります。
正規表現で部分一致に名前を付けて取り出そうとするとエラーが返り、後が続きません
import re
pattern = re.compile('(?P<first_name>[a-z]+)
File "<stdin>", line 1
pattern = re.compile('(?P<first_name>[a-z]+)
^
SyntaxError: EOL while scanning string literal
result = pattern.search('John Lennon')
result.group('first_name')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'group'
このようになります。コードが間違っているのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/02/07 08:08
2017/02/07 08:24
2017/02/07 08:30
2017/02/07 08:43
2017/02/08 00:06
2017/02/08 00:57
2017/02/08 03:29