【发布时间】:2018-12-06 09:37:59
【问题描述】:
以下代码用于查找给定字符串的电子邮件地址。但是当我打印出来时,它只给出了内存位置。那么如何获取以下代码中的值?我正在使用 Python 2.7。我认为以下代码是用 Python3 编写的。
import re
emails = '''
CoreyMSchafer@gmail.com
corey.schafer@university.edu
corey-321-schafer@my-work.net
'''
pattern = re.compile(r'[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+')
matches = pattern.finditer(emails)
for match in matches:
print match
来源:https://github.com/CoreyMSchafer/code_snippets/blob/master/Python-Regular-Expressions/simple.py
【问题讨论】:
-
你的意思是打印
match.group(0)可能不是匹配对象
标签: python regex python-2.7