dic = {'张三':123, '李四':456, '王二娃':789}csvFile3 = open('ming.csv','w')writer2 = csv.writer(csvFile3)for key in dic:writer2.writerow([key, dic[key]])csvFile3.close() 当打开文件的格式为“W”的时候,每次会把当前的
dic = {'张三':123, '李四':456, '王二娃':789} csvFile3 = open('ming.csv','w') writer2 = csv.writer(csvFile3) for key in dic: writer2.writerow([key, dic[key]]) csvFile3.close()
当打开文件的格式为“W”的时候,每次会把当前的文件内容覆盖掉。 当设置为“a”时,则会按行追加:
但是怎么让它按列追加呢?