How do I put single-quotes around string using Python csv writer?

Viewed 10976
with open("emails.csv", "w") as csvfile:
    for control_rent_email in control_group_renters:
        email_writer = csv.writer(csvfile, quotechar='"', quoting=csv.QUOTE_NONNUMERIC,delimiter=',')
        email_writer.writerow([control_rent_email])
    csvfile.close()

I get the following output in the "emails.csv":

"susan@gmail.com"
"joe@gmail.com"
"sara@yahoo.com"

But I want the output to be

'susan@gmail.com',
'joe@gmail.com',
'sara@yahoo.com'

How do I put the correct parameters in csv.writer() to achieve this desired result?

UPDATE:

1)

email_writer = csv.writer(csvfile, quotechar=''', quoting=csv.QUOTE_NONNUMERIC,delimiter=',')                                                                                            
SyntaxError: EOL while scanning string literal

2) How do I place the "," to look like the output result?

4 Answers
Related