我建议你用
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)
编辑:
更改了代码,以便正确回答您的问题