如何使用python检查电子邮件ID列表并删除无用/大写的电子邮件ID

时间:2019-03-20 16:01:18

标签: python regex

我有一个json文件,我提取了一个电子邮件ID列表-特别是两个列表(垃圾邮件和合法电子邮件),但是在这些列表中,我想消除大写,数字等电子邮件ID。我把那些人排除在外了吗?

with open(filename, 'r') as fp:
    json_decode = json.loads(fp.read())
    line = str(json_decode)

    # find all emails
    match = re.findall(r'[\w\.-]+@[\w.-]+', line)

    legit = []
    spam = []

    for email in match:
        email_status = email.endswith("gmail.com")
        if email_status == False:
            spam.append(email)
        else:

输出:

     The legit list is {'taylor.l@gmail.com', '6ca63336ba8b483ca5f543cbad585fbb@gmail.com', 'Taylor.L@gmail.gov', 'abuse@gmail.com'} I want only one element - {'taylor.l@gmail.com'} and it's not always the first element in the list.

      The spam list is {'n@TENT...', 'arealjcl@countable.us', 'image001.png@01D36CD8.2A2219D0', 'e8a1fdc83d13a56f4dbffdeb5942eba0@pisicano.cf'} and I want to remove everything except {'arealjcl@countable.us'}

如何使用正则表达式提出消除我不需要的电子邮件ID的条件?

0 个答案:

没有答案