Python文本处理

提取电子邮件地址

提取电子邮件地址详细操作教程
要从文本中提取电子邮件,我们可以使用正则表达式。 在下面的示例中,借助正则表达式包来定义电子邮件ID的模式,然后使用findall()函数来检索与此模式匹配的文本。
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-23
import re
text = "Please contact us at xxx@qq.com for further information."+\
        " You can also give feedbacl at xxx@lidihuo.com"
emails = re.findall(r"[a-z0-9\.\-+_]+@[a-z0-9\.\-+_]+\.[a-z]+", text)
print emails
执行上面示例代码,得到以下结果 -
['xxx@qq.com', 'xxx@lidihuo.com']
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4