通过显示路径从文本文件中提取电子邮件id

2024-10-01 07:35:30 发布

您现在位置:Python中文网/ 问答频道 /正文


我的文本文件保存在我的桌面上,其中包含我的简历我想从文本文件中提取我的电子邮件有人能帮我吗 我的txt文件有

Name                        :      K. Spandana

Gender                      :      Female

Nationality                 :      Indian

Marital Status              :      Unmarried
Mother tongue               :      Telugu
Languages Known             :      English, Hindi and Telugu
Address of Correspondence   :      H.NO:4-56/1, Hanuman nagar ,Post: Theegalaguttapalli,

E-mail ID                   :      Spandanareddy.kallepu@gmail.com

我试过了 https://gist.github.com/dideler/5219706具有文件路径的代码


Tags: 文件nametxtcom电子邮件statusgenderfemale
1条回答
网友
1楼 · 发布于 2024-10-01 07:35:30

下面这样的方法会起作用:

with open('resume.txt', 'r') as f_input:
    print re.findall(r'\b([a-z0-9-_.]+?@[a-z0-9-_.]+)\b', f_input.read(), re.I)

它将显示:

^{pr2}$

但确切的逻辑可以是far more complicated。这完全取决于它需要多精确。在

这将显示文本文件中的所有电子邮件地址,以防万一不止一个。在

相关问题 更多 >