我有一个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'}
如何使用regex来提出一个条件来消除我不需要的电子邮件id?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐