import csv
villains = [
    {'first':'Doctor', 'last':'No'}, 
    {'first':'Rosa', 'last':'Klebb'}, 
    {'first':'Mister', 'last':'Big'}, 
    {'first':'Auric', 'last':'Goldfinger'}, 
    {'first':'Ernst', 'last':'Blofeld'}, 
    ]


with open('villains','wt', newline='') as fout:

    cout = csv.DictWriter(fout, ['first','last'])
    cout.writeheader()
    cout.writerows(villains)


import csv
villains = [
    {'first':'Doctor', 'last':'No'}, 
    {'first':'Rosa', 'last':'Klebb'}, 
    {'first':'Mister', 'last':'Big'}, 
    {'first':'Auric', 'last':'Goldfinger'}, 
    {'first':'Ernst', 'last':'Blofeld'}, 
    ]


with open('villains','wt', newline='') as fout:

    cout = csv.DictWriter(fout, ['first','last'])
    cout.writeheader()
    cout.writerows(villains)

