Comment lire et écrire des fichiers CSV avec Python?

J'ai un fichier example.csv avec le contenu

1,"A towel,",1.0
42," it says, ",2.0
1337,is about the most ,-1
0,massively useful thing ,123
-2,an interstellar hitchhiker can have.,3

Comment puis-je lire ce example.csv avec Python?

De la même façon, si j'ai

data = [(1, "A towel,", 1.0),
        (42, " it says, ", 2.0),
        (1337, "is about the most ", -1),
        (0, "massively useful thing ", 123),
        (-2, "an interstellar hitchhiker can have.", 3)]

Comment puis-je écrire data vers un fichier CSV avec Python?

Ceci est destiné à être un canonique question comme je viens de le trouvé beaucoup de doublons qui encadrent la question différemment, mais sont essentiellement cette question.
Exemples de dupes: stackoverflow.com/questions/5788521/... stackoverflow.com/questions/26903304/... stackoverflow.com/questions/1593318/... stackoverflow.com/questions/24662571/python-import-csv-to-list stackoverflow.com/questions/34568774/... stackoverflow.com/questions/14725020/read-csv-file-from-python stackoverflow.com/questions/16283799/... ...
Plus de doublons venir quand vous faites une recherche google pour "python lire csv stackoverflow"

OriginalL'auteur Martin Thoma | 2017-01-11