社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

Siddharth Dushantha

Siddharth Dushantha 最近创建的主题
Siddharth Dushantha 最近回复了
6 年前
回复了 Siddharth Dushantha 创建的主题 » 如何从特定域中排除电子邮件地址,并通过pythonical方法提取其他地址

我建议你用 endswith() 功能。以下是您使用它的方法:

legit = []
spam = []

# We iterate through the list of matches
for email in match:

    # This checks if the email ends with @gmail.com.
    # If it returns True, that means it is a good email.
    # But, if it returns False, then it means that the email
    # is spam.
    email_status = email.endswith("@gmail.com")


    if email_status == False:
        spam.append(email)

    else:
        legit.append(email)

编辑: 更改了代码,以便正确回答您的问题