Computer >> 컴퓨터 >  >> 프로그램 작성 >> Python

URL 텍스트 파일에서 이메일 ID를 추출하는 Python 프로그램

<시간/>

여기에서는 URL 텍스트 파일에서 이메일 ID를 추출하기 위해 정규식 패키지를 사용하고 있습니다. 주어진 URL-텍스트 파일. 정규식 패키지를 사용하여 email-id의 패턴을 정의한 다음 findall() 함수를 사용하여 이 패턴과 일치할 텍스트를 확인하기 위해 이 메소드를 사용합니다.

Input
text= Please contact us at contact@tutorialspoint.com for further information."+\  " You can also give feedback at feedback@tutorialspoint.com"
Output ['contact@tutorialspoint.com ','feedback@tutorialspoint.com']

예시 코드

import re
my_text = "Please contact us at contact@tutorialspoint.com for further information."+\
   " You can also give feedback at feedback@tutorialspoint.com"
my_emails = re.findall(r"[a-z0-9\.\-+_]+@[a-z0-9\.\-+_]+\.[a-z]+", my_text)
print (my_emails)

출력

['contact@tutorialspoint.com', 'feedback@tutorialspoint.com’]