I have a small script:
#!/usr/bin/python3.2
#takes the bad_emails out of full_emails and leaves us with good_emails
#This is a manually generated list of bad emails (bounce backs)
bad_list = []
with open("bad_emails.txt","r") as bad:
for line in bad.readlines():
bad_list.append(line)
#this is a list of ALL email addresses output by AcyMailing
full_emails = []
with open("full_emails.txt","r") as full:
for email in full.readlines():
if email in bad_list:
pass
else:
full_emails.append(email)
#this is a final list containing only the email addresses with want
good_list = []
with open("good_emails","w") as good:
for email in full_emails:
good.write(email)
What I’m attempting to do is in short: take a list of email addresses from our mailer program called AcyMailing in Joomla and export it out. It has the following format:
“abc@abc.com”
“def@def.com”
“etc@etc.etc”
While my above script works (it gets rid of the ‘bad emails’ and leaves me with only the ‘good emails’ I’ve yet to find a way to make each email surrounded by quotation marks like AcyMailing (Joomla) uses. I’ve seen that a number of people use regex for such a task. Is that the only way to do this in python?
You should be able to just wrap the string in quotes:
Or you can use
.format: