你可以这样做:
import csv# note: If you use 'b' for the mode, you will get a TypeError# under Python3. You can just use 'w' for Python 3data=[('smith, bob',2),('carol',3),('ted',4),('alice',5)]with open('ur file.csv','wb') as out: csv_out=csv.writer(out) csv_out.writerow(['name','num']) for row in data: csv_out.writerow(row) # You can also do csv_out.writerows(data) instead of the for loop输出文件将具有:
name,num"smith, bob",2carol,3ted,4alice,5


![将有序元组列表另存为CSV [重复] 将有序元组列表另存为CSV [重复]](http://www.mshxw.com/aiimages/31/626311.png)
