import csv data=[] file1=open("xx2.csv",mode="w") writer=csv.writer(file1) with open("sc.csv",'r',encoding='utf-8') as file: reader=csv.DictReader(file) ab=0 for row in reader: data=[] ab=ab+1 data.append(ab) data.append(row["v1"]) data.append(row["v2"]) data.append(row["v3"]) data.append(row["v4"]) data.append(row["v5"]) data.append(row["v6"]) data.append(row["v7"]) data.append(row["v8"]) data.append(row["v9"]) data.append(row["v10"]) data.append(row["v11"]) data.append(row["v12"]) data.append(row["v13"]) data.append(row["v14"]) data.append(row["v15"]) data.append(row["v16"]) data.append(row["v17"]) data.append(row["v18"]) data.append(row["v19"]) data.append(row["v20"]) data.append(row["v21"]) data.append(row["v22"]) data.append(row["v23"]) data.append(row["v24"]) data.append(row["v25"]) print(row["v1"],row["v2"],row["v3"]) if ab>50: break pass writer.writerow(data) file1.close()
标签:file1,ab,PYTHON,读写,CSV,data,csv,append,row From: https://www.cnblogs.com/xkdn/p/17624446.html